Out of curiosity, what do you find poorly designed about them? In my opinion many of these things are elegant to the point of self documentation. Switch case pattern matching in particular is just great:
void foo()
{
object pi = 3.14d;
switch (pi)
{
case int i:
Console.WriteLine("pi is an int of value " + i);
break;
case float f:
Console.WriteLine("pi is a float of value " + f);
break;
case double d:
Console.WriteLine("pi is a double of value " + d);
break;
default:
Console.WriteLine("pi is of an unknown type.");
break;
}
}
Elegance is of course in the eye of the beholder, so what would you propose as an improvement to something like this?
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.";
});
}