Deal with the arguments : Main « Language Basics « C# / C Sharp
- C# / C Sharp
- Language Basics
- Main
Deal with the arguments
using System;
class SayHello {
public static void Main(string[] args) {
if (args.Length > 0) {
foreach (string arg in args) {
if (arg.Equals("/help"))
Console.WriteLine("Run this program as follows: sayhello.exe [name1] ");
else
Console.WriteLine("Hello " + "{0}", arg);
}
} else
Console.WriteLine("For help, run sayhello.exe /help");
}
}
Related examples in the same category