You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow direct assignment and use of a property's backing field during construction, without having to invoke the setter, via a new fieldof(Prop) expression.
classC{publicC(DataStorestore){this.store=store;// allows giving an initial value for 'this.Prop'// without calling 'Store.WritePropToDisk()' thru the setterfieldof(this.Prop)= store.ReadPropFromDisk();// 'fieldof()' allows general usage of the field from an initialization context, a la writability of 'readonly' fields.M(reffieldof(this.Prop));}voidMethod(){// error: 'fieldof' can only be used during initializationfieldof(this.Prop)= "a";
}privateDataStorestore;publicstringProp{get=>field;set{if(value!=field){field=value;store.WritePropToDisk(value);}}}}
Design meetings
The text was updated successfully, but these errors were encountered:
fieldof()
field
keyword in properties #8635Summary
Allow direct assignment and use of a property's backing field during construction, without having to invoke the setter, via a new
fieldof(Prop)
expression.Design meetings
The text was updated successfully, but these errors were encountered: