List of Switch case programs in C# with an examples

Switch case statements are an alternate method for long if statements that compare a variable to several 'integral' values. The value of the variable given into switch is compared to the value following each of the cases, and when one value matches the value of the variable, the computer continues executing the program at that point.


techstudy.org

Kindle Paperwhite High Resolution Display Tablet | Rs. 9999

The basic format for using switch case is outlined below.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
switch (n)
{
    case this-value:
        // code to be executed if n is equal to  this-value
        break;

    case this-value2:
        // code to be executed if n is equal to this-value2
        break;
        .
        .
        .
    default:
        // code to be executed if n doesn't match any of the cases
}






Related Topics



Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.