3 ms·
Although I 100% agree with you on the expression based properties, the argument against that would be that it doesn't follow the norms for the language as a who
by louthy 13y ago
Although I 100% agree with you on the expression based properties, the argument against that would be that it doesn't follow the norms for the language as a whole. First class functions are definitely an afterthought for C#, so making this a Func<double> would go against that I reckon:
public double Dist => Sqrt(X * X + Y * Y);
> I'm also concerned about the idea (only 'planned' for now, I believe) for the same syntax for methods which take arguments, though.
Where's this? I must have missed it. Or could you show what it would look like?
- jameshart 13y agoWell note that the feature is described as "expression-bodied members", not "expression-bodied readonly properties". In Mads's "Future of C#" presentation where most of these features were first floated, he described using the syntax for declaring methods as well as properties: public Point Move(int dx, int dy) => new Point(X + dx, Y + dy); Which is logically consistent with the property syntax, but as I say, I have my reservations about it.