Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7807029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:43:26+00:00 2026-06-02T02:43:26+00:00

Question: How do you read multiple commands/variables/modifiers from a single line of user input?

  • 0

Question: How do you read multiple commands/variables/modifiers from a single line of user input?

Much like any CLI such as Command Prompt would do, the user enters a single line and variables + modifiers are read and assigned from it.

E.G. A conversion program command:

32 km to cm

Then it reads:

numToConvert = (32)

then

"km to cm"

points to conversionRate1

 conversionRate1 = (0.621371192)

multiply 32 by conversion rate (0.621371192)

print Result.

Second Example:

shutdown -h

or

shutdown /?

shutdown is read as a command

-h modifies it or /? modifies it

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:43:27+00:00Added an answer on June 2, 2026 at 2:43 am

    Anything given on the commandline, after the program name, is split on whitespace, and passed in to the args array.

    So, given:

    class Program
    {
        static void Main(string[] args)
        {
            foreach (var a in args)
            {
                Console.WriteLine(a);
            }
        }
    }
    

    running “c:>program.exe convert foo to bar” will produce the lines

    convert
    foo
    to
    bar
    

    In order to parse out the semantic meaning, you will need to scan the args array and look for the modifiers.

    If you’ve got strict syntax, you can simply look in the expected position

    var numToConvert = Convert.toint32(args[4])
    

    If you’re allowing flexible syntax it will be more complex; you will need to develop a series of parsing rules to help you make sense of the input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The string in question (read from a file): if (true) then { _this =
I am asking a question that is related to Execute multiple SQL commands in
Original Question: i read that for RESTful websites. it is not good to use
I read a question earlier asking if there was a times method in Python,
I read this question but the answer does not perform a refactoring of the
Having read this question Immutable or not immutable? and reading answers to my previous
Update: Please read this question in the context of design principles, elegance, expression of
I recently read a question on here about static and dynamic linking, which reminded
I have read this question but it's not quite what I was looking for.
You can read this question where I ask about the best architecture for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.