Access property backing field from inside property #7742
Answered
by
AndersKehlet
DJDoena
asked this question in
Language Ideas
-
if you have a standard auto-implemented Property
C# will generate a backing field in the compiled code that is not accessible (outside reflection) from the rest of the class. However if you need to do some value checks like this:
you need an explicit field that is now accessible from the rest of the code. It would be great to have the backing field only accessible for the property itself, like this:
or like this
in both proposal cases the backing field should not be accessible by regular code outside the property itself |
Beta Was this translation helpful? Give feedback.
Answered by
AndersKehlet
Dec 6, 2023
Replies: 1 comment 4 replies
-
They're working on it. |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
DJDoena
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/dotnet/csharplang/blob/4dba3f29032a8164fa243a39b56e3a426a7995fc/proposals/semi-auto-properties.md
They're working on it.