14.eight.4 Instantly observed functions
An automatically adopted assets (otherwise auto-assets for brief), is a non-conceptual, non-extern possessions having semicolon-just accessor authorities. Auto-properties will has actually a score accessor and may even optionally features a great place accessor.
When a property is actually given once the an instantly used assets, a hidden backing field is actually immediately designed for the home, together with accessors try used to see away from and you will write to help you you to support career. The fresh hidden support occupation was inaccessible, it can be see and created just through the automatically then followed property accessors, also in the who has type of. If for example the auto-assets does not have any lay accessor, this new backing field represents readonly (§14.5.3). Just like a beneficial readonly profession, a beneficial getter-merely car-assets can be assigned to within the body regarding a great constructor of your enclosing category. Such as a project assigns directly to the fresh read-only support field of the property.
14.eight.5 Use of
In the event the an enthusiastic accessor keeps an accessor_modifier, this new access to domain name (§eight.5.3) of your accessor is decided using the announced the means to access of accessor_modifier. In the event the an enthusiastic accessor doesn’t always have a keen accessor_modifier, the newest entry to domain name of accessor is set in the announced accessibility of the house or indexer.
The existence of an accessor_modifier never ever influences user lookup (§11.5) otherwise overburden solution (§11.six.4). The new modifiers towards possessions otherwise indexer constantly determine which property otherwise indexer will, whatever the perspective of your availableness.
Immediately after a certain property or indexer might have been chose, new the means to access domains of one’s specific accessors inside are used http://datingranking.net/pl/loveandseek-recenzja to determine if one to use is true:
- If for example the usage is really as an esteem (§11.2.2), brand new score accessor will are present and become accessible.
- When your usage can be the goal from a straightforward project (§.2), the fresh new put accessor shall are present and be accessible.
- Whether your usage is just as the target off material assignment (§.3), otherwise because the address of your own ++ otherwise — operators (§11.7.14, §eleven.8.6), both the rating accessors and lay accessor will exists and you will be accessible.
Example: About adopting the example, the house A great.Text are invisible by property B.Text message , in contexts in which precisely the set accessor is called. On the other hand, the home B.Count isn’t available to category Meters , so that the obtainable assets A beneficial.Amount can be used as an alternative.
An enthusiastic accessor that is used to implement a program should perhaps not enjoys a keen accessor_modifier. Only if one to accessor is employed to make usage of a software, the other accessor may be proclaimed which have a keen accessor_modifier:
An online assets report specifies your accessors of the home try digital. Brand new virtual modifier pertains to all the low-private accessors away from property. When an accessor from a virtual assets has the individual accessor_modifier, the personal accessor try implicitly perhaps not virtual.
An abstract property report determine that the accessors of the property try virtual, however, does not render a real utilization of the newest accessors. As an alternative, non-conceptual derived groups have to bring their own implementation for new accessors of the overriding the home. Given that a keen accessor for a conceptual possessions report provides not any implementation, its accessor_human body only includes an excellent semicolon. An abstract property will n’t have an exclusive accessor.
Property declaration detailed with both the abstract and you will override modifiers determine that property is conceptual and you can overrides a base assets. This new accessors of such a property are also abstract.
Conceptual assets declarations are just permitted in abstract classes (§fourteen.dos.dos.2). The fresh accessors from an inherited virtual assets would be overridden in the an excellent derived category of the along with a property statement you to specifies a keen bypass directive. This is certainly also known as an enthusiastic overriding assets report. An overriding assets declaration doesn’t declare another possessions. As an alternative, it really focuses brand new implementations of the accessors away from a preexisting virtual possessions.
0 responses on "fourteen.7.six Virtual, closed, override, and conceptual accessors"