Re:How many keywords I can fit into a single C# expression?
by rjf72 on Thursday February 07, 2019 @12:57AM
(#19103354)
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:
Elegance is of course in the eye of the beholder, so what would you propose as an improvement to something like this?
[ Parent
| on HN ]
Re:How many keywords I can fit into a single C# expression?
by vermorel on Thursday February 07, 2019 @02:10AM
(#19103591)
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!