1

I am trying to make a C# application that takes command line arguments (username and password) and declares them both as variables, so I would give arguments Bob and 12345, and it would save Bob as variable: Username, and 12345 as variable: Password. How would I do this?

3
  • Total incorrect flag as duplicate @Kevin, the question is way simpler Commented Mar 1, 2013 at 1:49
  • You're right. My bad. Commented Mar 1, 2013 at 1:51
  • No, that's about options that don't change each run. Still not the same. Commented Mar 1, 2013 at 1:52

1 Answer 1

4

You can do this using Command Line Arguments.

Example:

public static void Main(string[] args)
   {
       //The arguments are 0 and 1, for the first and second args.
       var username = args[0];
       var password = args[1];
   }
Sign up to request clarification or add additional context in comments.

3 Comments

Oh, thank you, I thought it would be much harder!
Glad to help. MSDN often has answers.
@ZacHeimgartner, most modern (and some old) languages can do this btw.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.