13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>C#</strong> LANGUAGE SPECIFICATIONproperty-modifier:newpublicprotectedinternalprivatestaticvirtualsealedoverrideabstractexternmember-name:identifierinterface-type . identifierA property-declaration may include a set of attributes (§24) and a valid combination of the four access modifiers(§17.2.3), the new (§17.2.2), static (§17.6.1), virtual (§17.5.3, §17.6.3), override (§17.5.4, §17.6.3),sealed (§17.5.5), abstract (§17.5.6, §17.6.3), and extern modifiers.Property declarations are subject to the same rules as method declarations (§17.5) with regard to validcombinations of modifiers.The type of a property declaration specifies the type of the property introduced by the declaration, and themember-name specifies the name of the property. Unless the property is an explicit interface memberimplementation, the member-name is simply an identifier. For an explicit interface member implementation(§20.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 (§10.5.4).The accessor-declarations, which must be enclosed in “{” and “}” tokens, declare the accessors (§17.6.2) of theproperty. 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 avariable. 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-declarationsconsists of a semicolon.17.6.1 Static and instance propertiesWhen a property declaration includes a static modifier, the property is said to be a static property. When nostatic 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 theaccessors of a static property.An instance property is associated with a given instance of a class, and that instance can be accessed as this(§14.5.7) in the accessors of that property.When a property is referenced in a member-access (§14.5.4) of the form E.M, if M is a static property, E mustdenote a type that has a property M, and if M is an instance property, E must denote an instance having aproperty M.The differences between static and instance members are discussed further in §17.2.5.17.6.2 AccessorsThe accessor-declarations of a property specify the executable statements associated with reading and writingthat property.240

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!