|
|
|
|
|
by newt
5725 days ago
|
|
The Expression tree part is powerful (you can inspect it with code, pull property names out, etc), but it's not needed in most cases. Your example in C# is: Func<int, int> f = x => x + 1;
int b = f(42);
This is shorter than the JavaScript. The C# is more verbose where has to specify a type for f because it cannot work it out from context (in fact the left side of the '=' supplies type information to the right side), but the actual expression on the right is less verbose than the JavaScript with its "function" and "return" keywords.If you want, the second line can be var b = f(42);
But it's the same number of chars. I don't think that you gain anything from letting the compiler work out that b is an int. |
|