Monday, January 16, 2012

Switch Case / Select Case VB.NET / C#

I needed to remember the syntax of the switch / case for the .net languages and then i decided to share them with you here too so you can learn or remember them too.

C#:
  switch (option)
    {
        case "option1":
            // code for case "option1"
            break;
        case "option2":
            // code for case "option2"
            break;
        default:
            //code for every other options
            break;
    }

VB.NET:
Select Case option
    Case "option1"
          ' code for case "option1"
    Case "option2"
          ' code for case "option2"
    Case Else 
          ' code for every other options
End Select
 

No comments:

Post a Comment