How to run a program using command line argument for example my program only runs when i say a string e.g Hello World if this value does not match then it should give an error.
if (args == null)
{
Console.WriteLine("cant be null"); // Check for null array
}
if (args[0].Contains("Hello World"))
{
Console.WriteLine("True"); // Check for null array
}
else
{
Console.WriteLine("Error"); // Check for null array
}
Thanks in advance.
Sumit Kesarwani
04-Sep-2013Write this code in your main method(I am considering you are doing this in a Console application);
Hope this helps you.