Skip to content
Discussion options

You must be logged in to vote

Make programmer to access the backing field of auto-implemented property when necessary to be use it with ref param.

At this point i would say that you shouldn't have an auto-prop.

MyMethod(ref fieldof(MyProp));

This is particularly concerning, because it makes how a property works no longer an implementation detail. For example, you couldn't change your property from an auto-prop to a completely computed prop as that would break anyone that did fieldof on it.

The reason to use a property in the first plcae, and not just use a field, is entirely because the impl should be hidden and can be updated/replaced in the future without breaking anything that would change this.

If you want ot …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@CyrusNajmabadi
Comment options

Answer selected by Flithor
Comment options

You must be logged in to vote
1 reply
@333fred
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #4146 on November 17, 2020 03:38.