// Get arguments using System.Environment.
string[] theArgs = Environment.GetCommandLineArgs();
foreach(string arg in theArgs)
Console.WriteLine("Arg: {0}", arg);
Console.ReadLine();
return -1;
}
Of course, it is up to you to determine which command-line arguments your program will
respond to (if any) and how they must be formatted (such as with a - or / prefix). Here we simply
passed in a series of options that were printed directly to the command prompt. Assume, however,
you were creating a new video game and programmed your application to process an option named
-godmode. If the user starts your application with the flag, you know the user is in fact a cheater, and
can take an appropriate course of action.
Do'stlaringiz bilan baham: |