Code Monkey

01 Feb

C# Switch Statement

The syntax for a switch statement (Select Case in VB) is as follows

Inside each case you can use any jump statement you wish: including gotos and continues:

 http://msdn2.microsoft.com/en-us/library/d96yfwee(VS.71).aspx

switch (value)

{
     case “a”:
          //dosomething
          break; //kicks out of the switch statement
     case “b”:
          //dosomething else
          break;
      case “c”:
          //dosomething again
          break;
      default;
          //do stuff
          break;
}

Leave a Reply

© 2009 Code Monkey | Entries (RSS) and Comments (RSS)

Global Positioning System Gazettewordpress logo