Answers for "how to write multiple switch statement in c#.net"

C#
4

can you have multiple statement in a case c#

switch (value)
{
    case 1: case 2: case 3:          
        // Do Something
        break;
    case 4: case 5: case 6: 
        // Do Something
        break;
    default:
        // Do Something
        break;
}
Posted by: Guest on August-20-2020
6

switch expression c# multiple cases

var switchValue = 3;
var resultText = switchValue switch
{
    1 or 2 or 3 => "one, two, or three",
    4 => "four",
    5 => "five",
    _ => "unknown",
};
Posted by: Guest on March-07-2021

Code answers related to "how to write multiple switch statement in c#.net"

C# Answers by Framework

Browse Popular Code Answers by Language