2009-12-09 Jb Evain <jbevain@novell.com>
[mcs.git] / docs / ecma334 / 17.2.xml
blob4eef91232f817afbb54907ba606feafa856f58e4
1 <?xml version="1.0"?>
2 <clause number="17.2" title="Class members">
3   <paragraph>The members of a class consist of the members introduced by its <non_terminal where="17.2">class-member-declaration</non_terminal>s and the members inherited from the direct base class. <grammar_production><name><non_terminal where="17.2">class-member-declaration</non_terminal>s</name> : <rhs><non_terminal where="17.2">class-member-declaration</non_terminal></rhs><rhs><non_terminal where="17.2">class-member-declarations</non_terminal><non_terminal where="17.2">class-member-declaration</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="17.2">class-member-declaration</non_terminal></name> : <rhs><non_terminal where="17.3">constant-declaration</non_terminal></rhs><rhs><non_terminal where="17.4">field-declaration</non_terminal></rhs><rhs><non_terminal where="17.5">method-declaration</non_terminal></rhs><rhs><non_terminal where="17.6">property-declaration</non_terminal></rhs><rhs><non_terminal where="17.7">event-declaration</non_terminal></rhs><rhs><non_terminal where="17.8">indexer-declaration</non_terminal></rhs><rhs><non_terminal where="17.9">operator-declaration</non_terminal></rhs><rhs><non_terminal where="17.10">constructor-declaration</non_terminal></rhs><rhs><non_terminal where="17.12">destructor-declaration</non_terminal></rhs><rhs><non_terminal where="17.11">static-constructor-declaration</non_terminal></rhs><rhs><non_terminal where="16.5">type-declaration</non_terminal></rhs></grammar_production></paragraph>
4   <paragraph>The members of a class are divided into the following categories: <list><list_item> Constants, which represent constant values associated with that class (<hyperlink>17.3</hyperlink>). </list_item><list_item> Fields, which are the variables of that class (<hyperlink>17.4</hyperlink>). </list_item><list_item> Methods, which implement the computations and actions that can be performed by that class (<hyperlink>17.5</hyperlink>). </list_item><list_item> Properties, which define named characteristics and the actions associated with reading and writing those characteristics (<hyperlink>17.6</hyperlink>). </list_item><list_item> Events, which define notifications that can be generated by that class (<hyperlink>17.7</hyperlink>). </list_item><list_item> Indexers, which permit instances of that class to be indexed in the same way as arrays (<hyperlink>17.8</hyperlink>). </list_item><list_item> Operators, which define the expression operators that can be applied to instances of that class (<hyperlink>17.9</hyperlink>). </list_item><list_item> Instance constructors, which implement the actions required to initialize instances of that class (<hyperlink>17.10</hyperlink>) </list_item><list_item> Destructors, which implement the actions to be performed before instances of that class are permanently discarded (<hyperlink>17.12</hyperlink>). </list_item><list_item> Static constructors, which implement the actions required to initialize that class itself (<hyperlink>17.11</hyperlink>). </list_item><list_item> Types, which represent the types that are local to that class (<hyperlink>16.5</hyperlink>). </list_item></list></paragraph>
5   <paragraph>Members that can contain executable code are collectively known as the function members of the class. The function members of a class are the methods, properties, events, indexers, operators, instance constructors, destructors, and static constructors of that class. </paragraph>
6   <paragraph>A <non_terminal where="17.1">class-declaration</non_terminal> creates a new declaration space (<hyperlink>10.3</hyperlink>), and the <non_terminal where="17.2">class-member-declaration</non_terminal>s immediately contained by the <non_terminal where="17.1">class-declaration</non_terminal> introduce new members into this declaration space. The following rules apply to class-member-declarations: <list><list_item> Instance constructors, destructors, and static constructors must have the same name as the immediately enclosing class. All other members must have names that differ from the name of the immediately enclosing class. </list_item><list_item> The name of a constant, field, property, event, or type must differ from the names of all other members declared in the same class. </list_item><list_item> The name of a method must differ from the names of all other non-methods declared in the same class. In addition, the signature (<hyperlink>10.6</hyperlink>) of a method must differ from the signatures of all other methods declared in the same class. </list_item><list_item> The signature of an instance constructor must differ from the signatures of all other instance constructors declared in the same class. </list_item><list_item> The signature of an indexer must differ from the signatures of all other indexers declared in the same class. </list_item><list_item> The signature of an operator must differ from the signatures of all other operators declared in the same class. </list_item></list></paragraph>
7   <paragraph>The inherited members of a class (<hyperlink>17.2.1</hyperlink>) are not part of the declaration space of a class. <note>[Note: Thus, a derived class is allowed to declare a member with the same name or signature as an inherited member (which in effect hides the inherited member). end note]</note> </paragraph>
8 </clause>