In .NET
properties are supposed to be first class citizens however in the IL
code property getters and setters are implemented as get_
PropertyName and set_
PropertyName.
class Property
{
int Value { get { return 42; } }
int get_Value() { return 6 * 9; }
void set_Value(int i) { } // Error even though Value is a read only property
}
Output:
error CS0082: Type 'SO.Property' already reserves a member called 'get_Value' with the same parameter types
error CS0082: Type 'SO.Property' already reserves a member called 'set_Value' with the same parameter types
Why did the designers of .NET
decide to use a name that may clash with user code? They could have used an illegal character (as Java uses $
for inner class stuff).