X hits on this document





244 / 396

Chapter ‎18   Unsafe code

member-name: identifier interface-type   .   identifier

A property-declaration may include a set of attributes (§‎17) and a valid combination of the four access modifiers (§‎10.2.3), the new (§‎10.2.2),  static (§‎10.5.2), virtual (§‎10.5.3), override (§‎10.5.4), sealed (§‎10.5.5), abstract (§‎10.5.6), and extern (§‎10.5.7) modifiers.

Property declarations are subject to the same rules as method declarations (§‎10.5) with regard to valid combinations of modifiers.

The type of a property declaration specifies the type of the property introduced by the declaration, and the member-name specifies the name of the property. Unless the property is an explicit interface member implementation, the member-name is simply an identifier. For an explicit interface member implementation (§‎13.4.1), the member-name consists of an interface-type followed by a “.” and an identifier.

The type of a property must be at least as accessible as the property itself (§‎3.5.4).

The accessor-declarations, which must be enclosed in “{” and “}” tokens, declare the accessors (§‎10.6.2) of the property. The accessors specify the executable statements associated with reading and writing the property.

Even though the syntax for accessing a property is the same as that for a field, a property is not classified as a variable. Thus, it is not possible to pass a property as a ref or out argument.

When a property declaration includes an extern modifier, the property is said to be an external property. Because an external property declaration provides no actual implementation, each of its accessor-declarations consists of a semicolon.

10.6.1 Static and instance properties

When a property declaration includes a static modifier, the property is said to be a static property. When no static modifier is present, the property is said to be an instance property.

A static property is not associated with a specific instance, and it is a compile-time error to refer to this in the accessors of a static property.

An instance property is associated with a given instance of a class, and that instance can be accessed as this (§‎7.5.7) in the accessors of that property.

When a property is referenced in a member-access (§‎7.5.4) of the form E.M, if M is a static property, E must denote a type containing M, and if M is an instance property, E must denote an instance of a type containing M.

The differences between static and instance members are discussed further in §‎10.2.5.

10.6.2 Accessors

The accessor-declarations of a property specify the executable statements associated with reading and writing that property.

accessor-declarations: get-accessor-declaration   set-accessor-declarationopt set-accessor-declaration   get-accessor-declarationopt

get-accessor-declaration: attributesopt   get   accessor-body

set-accessor-declaration: attributesopt   set   accessor-body

Copyright Microsoft Corporation 1999-2003. All Rights Reserved.231

Document info
Document views741
Page views741
Page last viewedFri Oct 28 22:09:04 UTC 2016