2009/09/05 09:27

How to implement switch statement in C# ?


switch statement executes a set of logic depending on the value of a given parameter.

The types of the values a switch statement operates on can be booleans, enums, integral types, and strings.

Following is the example.

switch( strName)
{
  case "james":  strResult="male"; break;
  case "jane": strResult="female"; break;
  default: strResult = "unkonwn"; break;
}

Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.