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?
-
Total incorrect flag as duplicate @Kevin, the question is way simplerChristian Stewart– Christian Stewart2013-03-01 01:49:43 +00:00Commented Mar 1, 2013 at 1:49
-
You're right. My bad.kemiller2002– kemiller20022013-03-01 01:51:09 +00:00Commented Mar 1, 2013 at 1:51
-
No, that's about options that don't change each run. Still not the same.Christian Stewart– Christian Stewart2013-03-01 01:52:34 +00:00Commented Mar 1, 2013 at 1:52
Add a comment
|
1 Answer
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];
}
3 Comments
Zac Heimgartner
Oh, thank you, I thought it would be much harder!
Christian Stewart
Glad to help. MSDN often has answers.
Tyler Crompton
@ZacHeimgartner, most modern (and some old) languages can do this btw.