How to provide help for console application
-
Hi All, I should write a help for my application in C#.NET at the command prompt. And the format at command prompt should be sample.exe /? or sample.exe/? Plz provide me the code to write this and i should show some help abt what that appliaction do when i press sample.exe/? at command prompt.. Plz HELP!!
-
Hi All, I should write a help for my application in C#.NET at the command prompt. And the format at command prompt should be sample.exe /? or sample.exe/? Plz provide me the code to write this and i should show some help abt what that appliaction do when i press sample.exe/? at command prompt.. Plz HELP!!
Change your main method so it looks similar to the following code snippet:
static void Main(string[] args)
{
if (args.Length != 0)
{// Evaluate the comand line arguments.
for (int index = 0; index < args.Length; index++)
{
if (args[index] == "/?")
{
// Print out help to console
return;
}
}
// No known command line argument received so show error and preferably help to
}
else
{
// No command line arguments so run your application as usual}
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
Hi All, I should write a help for my application in C#.NET at the command prompt. And the format at command prompt should be sample.exe /? or sample.exe/? Plz provide me the code to write this and i should show some help abt what that appliaction do when i press sample.exe/? at command prompt.. Plz HELP!!
the parameters of the Main method are "string[] args". that means that you receive the arguments the user gives you in the command line (arguments = the words after sample.exe). if you want to check if you received /? in the command line, simple check what is the string in args[0].
if(args.Length > 0) // check if there are arguments to prevent exception { if(args[0] == "/?") { // you code } }
-
Hi All, I should write a help for my application in C#.NET at the command prompt. And the format at command prompt should be sample.exe /? or sample.exe/? Plz provide me the code to write this and i should show some help abt what that appliaction do when i press sample.exe/? at command prompt.. Plz HELP!!