C# Select Case = Switch

If like me you have converted from VB.Net to C# then this is a handy bit of code:

VB Version:

Dim iSwitch as Integer = 1
Dim iOut as Integer

Select Case iSwitch
Case 1
         iOut = 1
Case 2
         iOut = 2
Case Else
         iOut = 3
End Select

''iOut = 1

C# Conversion

int iSwitch = 1;
int iOut = 0;

switch (iSwitch )
{
       case 1:
                 iOut = 1;
                 break;
       case 2:
                 iOut = 2;
                 break;
       default:
                 iOut = 3;
                 break;
}

//iOut is = 1;

Thanks, Adrian
Posted: Nov 27 2008, 20:29 by Adrian | Comments (633) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: ASP.Net 2.0 | VB.Net | C#

Comments

Add comment


 

  Country flag

biuquote
  • Comment
  • Preview
Loading