Why do setters and getters interfere with get_X and set_X methods?

The .NETproperties must be first-class citizens, however in the code properties ILgetter and seters 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 named "get_Value" with the same parameters

error CS0082: Type "SO.Property" already reserves a member named "set_Value" with the same parameters

Why did the designers .NETdecide to use a name that might interfere with the user code? They could use an illegal character (as Java uses $for the inner class).

+5
4

, , J # ( ), - .

+8

Common Language Specification (CLS) get_ set_ IL ( ) Properties, , (#, ++, VB.NET, J #, IronPython ..) -.

, "" . CLS - .

. CLS- MSDN.

+7

, , .

+2

. , ( ), , . , ( ) - , Microsoft .

, , , , Microsoft, , , "" .

+1

All Articles