-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scoping private variables within a class #1712
Comments
A better name for this would be "property scoped variables." Also, please reformat your code |
mea culpa - I did this without searching. |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my most common use case of property backing fields I would like to be able to be sure that the private field is not modified externally to the property setter. To visually indicate this I commonly declare the field above the property. It would be great to have this ensured by the compiler by having the variable scoped within the property perhaps like this:
public Type PropertyName {
private Type field;
get => field;
set => setMethod(ref field, value);
}
The text was updated successfully, but these errors were encountered: