Advertisement
ChaosTheosis

SwitchCase

Jan 25th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Tutorial_Project_1.Tutorial_1_Examples
  8. {
  9.  
  10.    //String is used to hold any text value.
  11.    //The case will check any of the string text values for the "Two" from the string j.
  12.    //If the value that is in string j does not match any of the values in the cases then it will go
  13.    //To the default value which displays "Value not found".
  14.    
  15.    
  16.     class SwitchCase
  17.     {
  18.         static void Main()
  19.         {
  20.             string j = "Two";
  21.  
  22.             switch (j)
  23.             {
  24.                 case "Zero":
  25.                     Console.WriteLine("Value is 0");
  26.                     break;
  27.                 case "One":
  28.                     Console.WriteLine("Value is 1");
  29.                     break;
  30.                 case "Two":
  31.                     Console.WriteLine("Value is 2");
  32.                     break;
  33.                 case "Three":
  34.                     Console.WriteLine("Value is 3");
  35.                     break;
  36.                 case "Four":
  37.                     Console.WriteLine("Value is 4");
  38.                     break;
  39.                 default:
  40.                     Console.WriteLine("Value not found");
  41.                     break;
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement