Before I started using self-implemented properties, I had learned that when assigning properties in the constructor (because of the potential for creating a property
reading only), I should assign directly to the private member of the property (which we would usually name with the name of the property with an underscore in front of it.
_name of the property.)
When I switched to using self-implemented properties, I kept the practice even by establishing that only private members should be referenced inside the property class. I understand that these self-implementing private members are called "backup fields".
Given the utility of the basic fields, I find it fascinating that they are invisible to intellisense until they are fully typed. In addition, I observed that when you automatically implement the property, it seems that you can assign to a
Reading only Property in the class of the property.
Considering the changes in the .net framework, I'm starting to wonder what is the "right" way to manage properties from the class. I understand that this is somewhat subjective, but I wonder if there are any disadvantages to the way I did it. So I'm left with some questions about how this works, and what are the implications for my (even minor) software design:
- Does the call of the property automatically implemented from the class of the property call it the
- Does the call of the property's backup field bypass this?
- Am I wasting (however some cycles) of processor using the property instead of the support field?
- Or do I expose myself to a potential problem in the future using the support fields?
What is the difference between assigning auto-implemented properties and assigning them directly to their backup fields?
It seems that this question almost overlaps software engineering and overflow according to the formulation. Please, let me know if I need to change the label or migrate it.