Suppose I have the following in classic C#:
public string Size(byte b)
{
switch (b)
{
case 0:
case 1:
return "small";
default:
return "big";
}
}
The C#8 developers correctly recognized that there is a lot of cruft in the syntax. So in C#8, I can write it more compactly like this:
public string SizeCs8(byte b)
=> b switch
{
0 => "small",
1 => "small",
_ => "big",
};
Definitely an improvement. But one thing bothers me. I have to repeat the value "small". Previously I didn't. I'm wondering if it is possible to do it the C#8 way without repeating the value "small"?