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 SPECIFICATION17.2 Class membersThe members of a class consist of the members introduced by its class-member-declarations and the membersinherited from the direct base class.class-member-declarations:class-member-declarationclass-member-declarations class-member-declarationclass-member-declaration:constant-declarationfield-declarationmethod-declarationproperty-declarationevent-declarationindexer-declarationoperator-declarationconstructor-declarationdestructor-declarationstatic-constructor-declarationtype-declarationThe members of a class are divided into the following categories:• Constants, which represent constant values associated with that class (§17.3).• Fields, which are the variables of that class (§17.4).• Methods, which implement the computations and actions that can be performed by that class (§17.5).• Properties, which define named characteristics and the actions associated with reading and writing thosecharacteristics (§17.6).• Events, which define notifications that can be generated by that class (§17.7).• Indexers, which permit instances of that class to be indexed in the same way as arrays (§17.8).• Operators, which define the expression operators that can be applied to instances of that class (§17.9).• Instance constructors, which implement the actions required to initialize instances of that class (§17.10)• Destructors, which implement the actions to be performed before instances of that class are permanentlydiscarded (§17.12).• Static constructors, which implement the actions required to initialize that class itself (§17.11).• Types, which represent the types that are local to that class (§16.5).Members that can contain executable code are collectively known as the function members of the class. Thefunction members of a class are the methods, properties, events, indexers, operators, instance constructors,destructors, and static constructors of that class.A class-declaration creates a new declaration space (§10.3), and the class-member-declarations immediatelycontained by the class-declaration introduce new members into this declaration space. The following rules applyto class-member-declarations:• Instance constructors, destructors, and static constructors must have the same name as the immediatelyenclosing class. All other members must have names that differ from the name of the immediately enclosingclass.• The name of a constant, field, property, event, or type must differ from the names of all other membersdeclared in the same class.• The name of a method must differ from the names of all other non-methods declared in the same class. Inaddition, the signature (§10.6) of a method must differ from the signatures of all other methods declared in212

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

Saved successfully!

Ooh no, something went wrong!