Well, C# 8 will be having something much nicer syntax actually:
void foo()
{
object pi = 3.14d;
Console.WriteLine(pi switch
{
int i => "pi is an int of value " + i,
float f => "pi is a float of value " + f,
double d => "pi is a double of value " + d,
_ => "pi is of an unknown type.";
});
}
Check-out https://neelbhatt.com/2018/05/19/c-8-0-expected-features-par... Cheers!