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?
Asked
Active
Viewed 3,003 times
1
-
Total incorrect flag as duplicate @Kevin, the question is way simpler – Christian Stewart Mar 01 '13 at 01:49
-
You're right. My bad. – kemiller2002 Mar 01 '13 at 01:51
-
No, that's about options that don't change each run. Still not the same. – Christian Stewart Mar 01 '13 at 01:52
1 Answers
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];
}

Christian Stewart
- 15,217
- 20
- 82
- 139
-
-
-
@ZacHeimgartner, most modern (and some old) languages can do this btw. – Tyler Crompton Mar 01 '13 at 01:52