New answers tagged

1

It is not possible due to the fundamentals of how the grammar and compiler works. Expressions are evaluated "bottom up", which means the expression MyClass.X evaluates to its int value before this result is fed as an argument the function. Your proposal seem to suggest that the context - the type of the parameter - could direct if the expression should be ...


2

The problem is that "MyClass.X" has a well-defined meaning, which is to call the getter on the property "X". The important thing to note is that, even though a method is being called, brackets are not required. On the other hand, when calling a regular method, such as when you call "Foo" in your example code, brackets are required to indicate that the ...


1

Foo.Do() meaning the invocation and Foo.Do being the,delegate is fine. Foo.X being the property as well as the getter delegate and the setter delegate depending on subtle context differences is confusing. Good features that aren't overwhelming good don't even get into C#, this seems like an actual bad one. If you want short write once code try Perl. There ...



Top 50 recent answers are included