I know that automatic properties must be determined by the get and set accessor methods, I also know that any of these accessories can be made invisible using an access modifier.
Is there a technical reason why the compiler is satisfied
public object Property { get; set; }
but not
public object Property { get; }
My (possibly incorrect) understanding of this code is that the compiler creates a support field that is hidden from the calling code like this:
private object hiddenField;
If the compiler can generate this, is there a reason why it cannot omit the set accessor function based on the presence (or absence thereof) of the setter in the property declaration.
I understand that this may be a problem of the scope of possibilities, and not a technical limitation, I also freely admit that I have not yet specified the C # language specification.
[ UPDATE 2 ]
Forgive me ... I'm an idiot: P, now I see, thanks to everyone for changing my senior moment /
source share