A switch
statement executes the statements that are associated with the value of a given expression, or a default of statements if no match exists.
The example
using System; class Test { static void Main(string[] args) { switch (args.Length) { case 0: Console.WriteLine("No arguments were provided"); break; case 1: Console.WriteLine("One arguments was provided"); break; default: Console.WriteLine("{0} arguments were provided"); break; } } }
switches on the number of arguments provided.