Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

C# Switch Statements

Console.WriteLine(GetDay(5));
Console.ReadLine();


static string GetDay(int dayNum)
{
    string dayName;

    switch (dayNum)
    {
        case 0:
            dayName = "Sunday";
                break;
       case 1:
            dayName = "Monday";
            break;
       case 2:
            dayName = "Tuesday";
            break;
        case 3:
            dayName = "Wednesday";
            break;
        case 4:
            dayName = "Thursday";
            break;
        case 5:
            dayName = "Friday";
            break;
        case 6: dayName = "Saturday";
                break;
        default:
            dayName = "Invalid Day Number";
            break;
    }

    return dayName;

}
Source by # #
 
PREVIOUS NEXT
Tagged: #Switch #Statements
ADD COMMENT
Topic
Name
4+4 =