C#C
C#12mo ago
Faker

Switch statements

Hello, consider the following code:

C#
int employeeLevel = 200;
string employeeName = "John Smith";

string title = "";

switch (employeeLevel)
{
    case 100:
        title = "Junior Associate";
        break;
    case 200:
        title = "Senior Associate";
        break;
    case 300:
        title = "Manager";
        break;
    case 400:
        title = "Senior Manager";
        break;
    default:
        title = "Associate";
        break;
}

Console.WriteLine($"{employeeName}, {title}"); 

Can the switch expression be a expression that evaluates to true or false? like age < 5? or the case pattern can they be an expression that evaluates to true or false like age < 5?
Was this page helpful?