Answers for "new switch case in c#"

C#
4

switch expression c#

//called: switch expressions

int number= 2;

string result = number switch
{
    0 => "zero",
    1 => "one",
    2 => "two",
    _ => "default"
};

Console.WriteLine(result);
Posted by: Guest on March-16-2022
0

switch c#

switch(expression) 
{
  case x:
    // code block
    break;
  case y:
    // code block
    break;
  default:
    // code block
    break;
}
Posted by: Guest on November-26-2020

C# Answers by Framework

Browse Popular Code Answers by Language