Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

7
mcs/docs/ecma334/1.xml Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<clause number="1" title="Scope" informative="true">
<paragraph>This clause is informative. </paragraph>
<paragraph>This ECMA Standard specifies the form and establishes the interpretation of programs written in the C# programming language. It specifies <list><list_item> The representation of C# programs; </list_item><list_item> The syntax and constraints of the C# language; </list_item><list_item> The semantic rules for interpreting C# programs; </list_item><list_item> The restrictions and limits imposed by a conforming implementation of C#. </list_item></list></paragraph>
<paragraph>This ECMA Standard does not specify <list><list_item> The mechanism by which C# programs are transformed for use by a data-processing system; </list_item><list_item> The mechanism by which C# applications are invoked for use by a data-processing system; </list_item><list_item> The mechanism by which input data are transformed for use by a C# application; </list_item><list_item> The mechanism by which output data are transformed after being produced by a C# application; </list_item><list_item> The size or complexity of a program and its data that will exceed the capacity of any specific data-processing system or the capacity of a particular processor; </list_item><list_item> All minimal requirements of a data-processing system that is capable of supporting a conforming implementation. </list_item></list></paragraph>
<paragraph>End of informative text. </paragraph>
</clause>

15
mcs/docs/ecma334/10.1.xml Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<clause number="10.1" title="Application startup">
<paragraph>Application startup occurs when the execution environment calls a designated method, which is referred to as the application's entry point. This entry point method is always named Main, and shall have one of the following signatures: <code_example><![CDATA[
static void Main() {...}
static void Main(string[] args) {...}
static int Main() {...}
static int Main(string[] args) {...}
]]></code_example></paragraph>
<paragraph>As shown, the entry point may optionally return an <keyword>int</keyword> value. This return value is used in application termination (<hyperlink>10.2</hyperlink>). </paragraph>
<paragraph>The entry point may optionally have one formal parameter, and this formal parameter may have any name. If such a parameter is declared, it must obey the following constraints: <list><list_item> The implementation shall ensure that the value of this parameter is not null. </list_item><list_item> Let args be the name of the parameter. If the length of the array designated by args is greater than zero, the array members args[0] through args[args.Length-1], inclusive, must refer to strings, called application parameters, which are given implementation-defined values by the host environment prior to application startup. The intent is to supply to the application information determined prior to application startup from elsewhere in the hosted environment. If the host environment is not capable of supplying strings with letters in both uppercase and lowercase, the implementation shall ensure that the strings are received in lowercase. <note>[Note: On systems supporting a command line, application parameters correspond to what are generally known as command-line arguments. end note]</note> </list_item></list></paragraph>
<paragraph>Since C# supports method overloading, a class or struct may contain multiple definitions of some method, provided each has a different signature. However, within a single program, no class or struct shall contain more than one method called Main whose definition qualifies it to be used as an application entry point. Other overloaded versions of Main are permitted, however, provided they have more than one parameter, or their only parameter is other than type string[]. </paragraph>
<paragraph>An application can be made up of multiple classes or structs. It is possible for more than one of these classes or structs to contain a method called Main whose definition qualifies it to be used as an application entry point. In such cases, one of these Main methods must be chosen as the entry point so that application startup can occur. This choice of an entry point is beyond the scope of this specification-no mechanism for specifying or determining an entry point is provided. </paragraph>
<paragraph>In C#, every method must be defined as a member of a class or struct. Ordinarily, the declared accessibility (<hyperlink>10.5.1</hyperlink>) of a method is determined by the access modifiers (<hyperlink>17.2.3</hyperlink>) specified in its declaration, and similarly the declared accessibility of a type is determined by the access modifiers specified in its declaration. In order for a given method of a given type to be callable, both the type and the member must be accessible. However, the application entry point is a special case. Specifically, the execution environment can access the application's entry point regardless of its declared accessibility and regardless of the declared accessibility of its enclosing type declarations. </paragraph>
<paragraph>In all other respects, entry point methods behave like those that are not entry points. </paragraph>
</clause>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<clause number="10.10" title="Execution order">
<paragraph>Execution shall proceed such that the side effects of each executing thread are preserved at critical execution points. A side effect is defined as a read or write of a volatile field, a write to a non-volatile variable, a write to an external resource, and the throwing of an exception. The critical execution points at which the order of these side effects must be preserved are references to volatile fields (<hyperlink>17.4.3</hyperlink>), lock statements (<hyperlink>15.12</hyperlink>), and thread creation and termination. An implementation is free to change the order of execution of a C# program, subject to the following constraints: <list><list_item> Data dependence is preserved within a thread of execution. That is, the value of each variable is computed as if all statements in the thread were executed in original program order. </list_item><list_item> Initialization ordering rules are preserved (<hyperlink>17.4.4</hyperlink> and <hyperlink>17.4.5</hyperlink>). </list_item><list_item> The ordering of side effects is preserved with respect to volatile reads and writes (<hyperlink>17.4.3</hyperlink>). Additionally, an implementation need not evaluate part of an expression if it can deduce that that expression's value is not used and that no needed side effects are produced (including any caused by calling a method or accessing a volatile field). When program execution is interrupted by an asynchronous event (such as an exception thrown by another thread), it is not guaranteed that the observable side effects are visible in the original program order. </list_item></list></paragraph>
</clause>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<clause number="10.2" title="Application termination">
<paragraph>Application termination returns control to the execution environment. </paragraph>
<paragraph>If the return type of the application's entry point method is <keyword>int</keyword>, the value returned serves as the application's termination status code. The purpose of this code is to allow communication of success or failure to the execution environment. </paragraph>
<paragraph>If the return type of the entry point method is <keyword>void</keyword>, reaching the right brace (<symbol>}</symbol>) which terminates that method, or executing a return statement that has no expression, results in a termination status code of 0. </paragraph>
<paragraph>Prior to an application's termination, destructors for all of its objects that have not yet been garbage collected are called, unless such cleanup has been suppressed (by a call to the library method GC.SuppressFinalize, for example). </paragraph>
</clause>

61
mcs/docs/ecma334/10.3.xml Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<clause number="10.4.1" title="Namespace members">
<paragraph>Namespaces and types that have no enclosing namespace are members of the global namespace. This corresponds directly to the names declared in the global declaration space. </paragraph>
<paragraph>Namespaces and types declared within a namespace are members of that namespace. This corresponds directly to the names declared in the declaration space of the namespace. </paragraph>
<paragraph>Namespaces have no access restrictions. It is not possible to declare private, protected, or internal namespaces, and namespace names are always publicly accessible. </paragraph>
</clause>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<clause number="10.4.2" title="Struct members">
<paragraph>The members of a struct are the members declared in the struct and the members inherited from the struct's direct base class System.ValueType and the indirect base class object. </paragraph>
<paragraph>The members of a simple type correspond directly to the members of the struct type aliased by the simple type: <list><list_item> The members of <keyword>sbyte</keyword> are the members of the System.SByte struct. </list_item><list_item> The members of <keyword>byte</keyword> are the members of the System.Byte struct. </list_item><list_item> The members of <keyword>short</keyword> are the members of the System.Int16 struct. </list_item><list_item> The members of <keyword>ushort</keyword> are the members of the System.UInt16 struct. </list_item><list_item> The members of <keyword>int</keyword> are the members of the System.Int32 struct. </list_item><list_item> The members of <keyword>uint</keyword> are the members of the System.UInt32 struct. </list_item><list_item> The members of <keyword>long</keyword> are the members of the System.Int64 struct. </list_item><list_item> The members of <keyword>ulong</keyword> are the members of the System.UInt64 struct. </list_item><list_item> The members of <keyword>char</keyword> are the members of the System.Char struct. </list_item><list_item> The members of <keyword>float</keyword> are the members of the System.Single struct. </list_item><list_item> The members of <keyword>double</keyword> are the members of the System.Double struct. </list_item><list_item> The members of <keyword>decimal</keyword> are the members of the System.Decimal struct. </list_item><list_item> The members of <keyword>bool</keyword> are the members of the System.Boolean struct. </list_item></list></paragraph>
</clause>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<clause number="10.4.3" title="Enumeration members">
<paragraph>The members of an enumeration are the constants declared in the enumeration and the members inherited from class object. </paragraph>
</clause>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<clause number="10.4.4" title="Class members">
<paragraph>The members of a class are the members declared in the class and the members inherited from the base class (except for class object which has no base class). The members inherited from the base class include the constants, fields, methods, properties, events, indexers, operators, and types of the base class, but not the instance constructors, destructors, and static constructors of the base class. Base class members are inherited without regard to their accessibility. </paragraph>
<paragraph>A class declaration may contain declarations of constants, fields, methods, properties, events, indexers, operators, instance constructors, destructors, static constructors, and types. </paragraph>
<paragraph>The members of object and string correspond directly to the members of the class types they alias: <list><list_item> The members of object are the members of the System.Object class. </list_item><list_item> The members of string are the members of the System.String class. </list_item></list></paragraph>
</clause>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<clause number="10.4.5" title="Interface members">
<paragraph>The members of an interface are the members declared in the interface and in all base interfaces of the interface, and the members inherited from class object. </paragraph>
</clause>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<clause number="10.4.6" title="Array members">
<paragraph>The members of an array are the members inherited from class System.Array. </paragraph>
</clause>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<clause number="10.4.7" title="Delegate members">
<paragraph>The members of a delegate are the members inherited from class System.Delegate. </paragraph>
</clause>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<clause number="10.4" title="Members">
<paragraph>Namespaces and types have members. <note>[Note: The members of an entity are generally available through the use of a qualified name that starts with a reference to the entity, followed by a &quot;.&quot; token, followed by the name of the member. end note]</note> </paragraph>
<paragraph>Members of a type are either declared in the type or inherited from the base class of the type. When a type inherits from a base class, all members of the base class, except instance constructors, destructors, and static constructors become members of the derived type. The declared accessibility of a base class member does not control whether the member is inherited-inheritance extends to any member that isn't an instance constructor, static constructor, or destructor. However, an inherited member may not be accessible in a derived type, either because of its declared accessibility (<hyperlink>10.5.1</hyperlink>) or because it is hidden by a declaration in the type itself (<hyperlink>10.7.1.2</hyperlink>). </paragraph>
</clause>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<clause number="10.5.1" title="Declared accessibility">
<paragraph>The declared accessibility of a member can be one of the following: <list><list_item> Public, which is selected by including a public modifier in the member declaration. The intuitive meaning of public is &quot;access not limited&quot;. </list_item><list_item> Protected, which is selected by including a protected modifier in the member declaration. The intuitive meaning of protected is &quot;access limited to the containing class or types derived from the containing class&quot;. </list_item><list_item> Internal, which is selected by including an internal modifier in the member declaration. The intuitive meaning of internal is &quot;access limited to this program&quot;. </list_item><list_item> Protected internal, which is selected by including both a protected and an internal modifier in the member declaration. The intuitive meaning of protected internal is &quot;access limited to this program or types derived from the containing class&quot;. </list_item><list_item> Private, which is selected by including a private modifier in the member declaration. The intuitive meaning of private is &quot;access limited to the containing type&quot;. </list_item></list></paragraph>
<paragraph>Depending on the context in which a member declaration takes place, only certain types of declared accessibility are permitted. Furthermore, when a member declaration does not include any access modifiers, the context in which the declaration takes place determines the default declared accessibility. <list><list_item> Namespaces implicitly have public declared accessibility. No access modifiers are allowed on namespace declarations. </list_item><list_item> Types declared in compilation units or namespaces can have public or internal declared accessibility and default to internal declared accessibility. </list_item><list_item> Class members can have any of the five kinds of declared accessibility and default to private declared accessibility. <note>[Note: A type declared as a member of a class can have any of the five kinds of declared accessibility, whereas a type declared as a member of a namespace can have only public or internal declared accessibility. end note]) </note></list_item><list_item> Struct members can have public, internal, or private declared accessibility and default to private declared accessibility because structs are implicitly sealed. Struct members introduced in a struct (that is, not inherited by that struct) cannot have protected or protected internal declared accessibility. <note>[Note: A type declared as a member of a struct can have public, internal, or private declared accessibility, whereas a type declared as a member of a namespace can have only public or internal declared accessibility. end note]) </note></list_item><list_item> Interface members implicitly have public declared accessibility. No access modifiers are allowed on interface member declarations. </list_item><list_item> Enumeration members implicitly have public declared accessibility. No access modifiers are allowed on enumeration member declarations. </list_item></list></paragraph>
</clause>

View File

@@ -0,0 +1,62 @@
<?xml version="1.0"?>
<clause number="10.5.2" title="Accessibility domains">
<paragraph>The accessibility domain of a member consists of the (possibly disjoint) sections of program text in which access to the member is permitted. For purposes of defining the accessibility domain of a member, a member is said to be top-level if it is not declared within a type, and a member is said to be nested if it is declared within another type. Furthermore, the text of an assembly is defined as all source text contained in all source files of that assembly, and the source text of a type is defined as all source text contained between the opening and closing &quot;{&quot; and &quot;}&quot; tokens in the <non_terminal where="17.1.3">class-body</non_terminal>, <non_terminal where="18.1.3">struct-body</non_terminal>, <non_terminal where="20.1.3">interface-body</non_terminal>, or <non_terminal where="21.1">enum-body</non_terminal> of the type (including, possibly, types that are nested within the type). </paragraph>
<paragraph>The accessibility domain of a predefined type (such as object, <keyword>int</keyword>, or <keyword>double</keyword>) is unlimited. </paragraph>
<paragraph>The accessibility domain of a top-level type T that is declared in a program P is defined as follows: <list><list_item> If the declared accessibility of T is public, the accessibility domain of T is the program text of P and any program that references P. </list_item><list_item> If the declared accessibility of T is internal, the accessibility domain of T is the program text of P. </list_item></list></paragraph>
<paragraph>
<note>[Note: From these definitions it follows that the accessibility domain of a top-level type is always at least the program text of the program in which that type is declared. end note]</note>
</paragraph>
<paragraph>The accessibility domain of a nested member M declared in a type T within a program P, is defined as follows (noting that M itself may possibly be a type): <list><list_item> If the declared accessibility of M is public, the accessibility domain of M is the accessibility domain of T. </list_item><list_item> If the declared accessibility of M is protected internal, let D be the union of the program text of P and the program text of any type derived from T, which is declared outside P. The accessibility domain of M is the intersection of the accessibility domain of T with D. </list_item><list_item> If the declared accessibility of M is protected, let D be the union of the program text of T and the program text of any type derived from T. The accessibility domain of M is the intersection of the accessibility domain of T with D. </list_item><list_item> If the declared accessibility of M is internal, the accessibility domain of M is the intersection of the accessibility domain of T with the program text of P. </list_item><list_item> If the declared accessibility of M is private, the accessibility domain of M is the program text of T. </list_item></list></paragraph>
<paragraph>
<note>[Note: From these definitions it follows that the accessibility domain of a nested member is always at least the program text of the type in which the member is declared. Furthermore, it follows that the accessibility domain of a member is never more inclusive than the accessibility domain of the type in which the member is declared. end note]</note>
</paragraph>
<paragraph>
<note>[Note: In intuitive terms, when a type or member M is accessed, the following steps are evaluated to ensure that the access is permitted: <list><list_item> First, if M is declared within a type (as opposed to a compilation unit or a namespace), a compile-time error occurs if that type is not accessible. </list_item><list_item> Then, if M is public, the access is permitted. </list_item><list_item> Otherwise, if M is protected internal, the access is permitted if it occurs within the program in which M is declared, or if it occurs within a class derived from the class in which M is declared and takes place through the derived class type (<hyperlink>10.5.3</hyperlink>). </list_item><list_item> Otherwise, if M is protected, the access is permitted if it occurs within the class in which M is declared, or if it occurs within a class derived from the class in which M is declared and takes place through the derived class type (<hyperlink>10.5.3</hyperlink>). </list_item><list_item> Otherwise, if M is internal, the access is permitted if it occurs within the program in which M is declared. </list_item><list_item> Otherwise, if M is private, the access is permitted if it occurs within the type in which M is declared. </list_item><list_item> Otherwise, the type or member is inaccessible, and a compile-time error occurs. end note]</list_item></list></note>
</paragraph>
<paragraph>
<example>[Example: In the example <code_example><![CDATA[
public class A
{
public static int X;
internal static int Y;
private static int Z;
}
internal class B
{
public static int X;
internal static int Y;
private static int Z;
public class C
{
public static int X;
internal static int Y;
private static int Z;
}
private class D
{
public static int X;
internal static int Y;
private static int Z;
}
}
]]></code_example>the classes and members have the following accessibility domains: <list><list_item> The accessibility domain of A and A.X is unlimited. </list_item><list_item> The accessibility domain of A.Y, B, B.X, B.Y, B.C, B.C.X, and B.C.Y is the program text of the containing program. </list_item><list_item> The accessibility domain of A.Z is the program text of A. </list_item><list_item> The accessibility domain of B.Z and B.D is the program text of B, including the program text of B.C and B.D. </list_item><list_item> The accessibility domain of B.C.Z is the program text of B.C. </list_item><list_item> The accessibility domain of B.D.X, B.D.Y, and B.D.Z is the program text of B.D. </list_item></list></example>
</paragraph>
<paragraph>
<example>As the example illustrates, the accessibility domain of a member is never larger than that of a containing type. For example, even though all X members have public declared accessibility, all but A.X have accessibility domains that are constrained by a containing type. end example]</example>
</paragraph>
<paragraph>As described in <hyperlink>10.4</hyperlink>, all members of a base class, except for instance constructors, destructors, and static constructors are inherited by derived types. This includes even private members of a base class. However, the accessibility domain of a private member includes only the program text of the type in which the member is declared. <example>[Example: In the example <code_example><![CDATA[
class A
{
int x;
static void F(B b) {
b.x = 1; // Ok
}
}
class B: A
{
static void F(B b) {
b.x = 1; // Error, x not accessible
}
}
]]></code_example>the B class inherits the private member x from the A class. Because the member is private, it is only accessible within the <non_terminal where="17.1.3">class-body</non_terminal> of A. Thus, the access to b.x succeeds in the A.F method, but fails in the B.F method. end example]</example> </paragraph>
</clause>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<clause number="10.5.3" title="Protected access for instance members">
<paragraph>When a protected instance member is accessed outside the program text of the class in which it is declared, and when a protected internal instance member is accessed outside the program text of the program in which it is declared, the access is required to take place through an instance of the derived class type in which the access occurs. Let B be a base class that declares a protected instance member M, and let D be a class that derives from B. Within the <non_terminal where="17.1.3">class-body</non_terminal> of D, access to M can take one of the following forms: <list><list_item> An unqualified <non_terminal where="10.8">type-name</non_terminal> or <non_terminal where="14.5">primary-expression</non_terminal> of the form M. </list_item><list_item> A <non_terminal where="14.5">primary-expression</non_terminal> of the form E.M, provided the type of E is D or a class derived from D. </list_item><list_item> A <non_terminal where="14.5">primary-expression</non_terminal> of the form base.M. </list_item></list></paragraph>
<paragraph>In addition to these forms of access, a derived class can access a protected instance constructor of a base class in a <non_terminal where="17.10">constructor-initializer</non_terminal> (<hyperlink>17.10.1</hyperlink>). </paragraph>
<paragraph>
<example>[Example: In the example <code_example><![CDATA[
public class A
{
protected int x;
static void F(A a, B b) {
a.x = 1; // Ok
b.x = 1; // Ok
}
}
public class B: A
{
static void F(A a, B b) {
a.x = 1; // Error, must access through instance of B
b.x = 1; // Ok
}
}
]]></code_example>within A, it is possible to access x through instances of both A and B, since in either case the access takes place through an instance of A or a class derived from A. However, within B, it is not possible to access x through an instance of A, since A does not derive from B. end example]</example>
</paragraph>
</clause>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<clause number="10.5.4" title="Accessibility constraints">
<paragraph>Several constructs in the C# language require a type to be at least as accessible as a member or another type. A type T is said to be at least as accessible as a member or type M if the accessibility domain of T is a superset of the accessibility domain of M. In other words, T is at least as accessible as M if T is accessible in all contexts in which M is accessible. </paragraph>
<paragraph>The following accessibility constraints exist: <list><list_item> The direct base class of a class type must be at least as accessible as the class type itself. </list_item><list_item> The explicit base interfaces of an interface type must be at least as accessible as the interface type itself. </list_item><list_item> The return type and parameter types of a delegate type must be at least as accessible as the delegate type itself. </list_item><list_item> The type of a constant must be at least as accessible as the constant itself. </list_item><list_item> The type of a field must be at least as accessible as the field itself. </list_item><list_item> The return type and parameter types of a method must be at least as accessible as the method itself. </list_item><list_item> The type of a property must be at least as accessible as the property itself. </list_item><list_item> The type of an event must be at least as accessible as the event itself. </list_item><list_item> The type and parameter types of an indexer must be at least as accessible as the indexer itself. </list_item><list_item> The return type and parameter types of an operator must be at least as accessible as the operator itself. </list_item><list_item> The parameter types of an instance constructor must be at least as accessible as the instance constructor itself. </list_item></list></paragraph>
<paragraph>
<example>[Example: In the example <code_example><![CDATA[
class A {...}
public class B: A {...}
]]></code_example>the B class results in a compile-time error because A is not at least as accessible as B. end example]</example>
</paragraph>
<paragraph>
<example>[Example: Likewise, in the example <code_example><![CDATA[
class A {...}
public class B
{
A F() {...}
internal A G() {...}
public A H() {...}
}
]]></code_example>the H method in B results in a compile-time error because the return type A is not at least as accessible as the method. end example]</example>
</paragraph>
</clause>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<clause number="10.5" title="Member access">
<paragraph>Declarations of members allow control over member access. The accessibility of a member is established by the declared accessibility (<hyperlink>10.5.1</hyperlink>) of the member combined with the accessibility of the immediately containing type, if any. </paragraph>
<paragraph>When access to a particular member is allowed, the member is said to be accessible. Conversely, when access to a particular member is disallowed, the member is said to be inaccessible. Access to a member is permitted when the textual location in which the access takes place is included in the accessibility domain (<hyperlink>10.5.2</hyperlink>) of the member. </paragraph>
</clause>

24
mcs/docs/ecma334/10.6.xml Normal file
View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<clause number="10.6" title="Signatures and overloading">
<paragraph>Methods, instance constructors, indexers, and operators are characterized by their signatures: <list><list_item> The signature of a method consists of the name of the method and the type and kind (value, reference, or output) of each of its formal parameters, considered in the order left to right. The signature of a method specifically does not include the return type, nor does it include the params modifier that may be specified for the right-most parameter. </list_item><list_item> The signature of an instance constructor consists of the type and kind (value, reference, or output) of each of its formal parameters, considered in the order left to right. The signature of an instance constructor specifically does not include the params modifier that may be specified for the right-most parameter. </list_item><list_item> The signature of an indexer consists of the type of each of its formal parameters, considered in the order left to right. The signature of an indexer specifically does not include the element type. </list_item><list_item> The signature of an operator consists of the name of the operator and the type of each of its formal parameters, considered in the order left to right. The signature of an operator specifically does not include the result type. </list_item></list></paragraph>
<paragraph>Signatures are the enabling mechanism for overloading of members in classes, structs, and interfaces: <list><list_item> Overloading of methods permits a class, struct, or interface to declare multiple methods with the same name, provided their signatures are unique within that class, struct, or interface. </list_item><list_item> Overloading of instance constructors permits a class or struct to declare multiple instance constructors, provided their signatures are unique within that class or struct. </list_item><list_item> Overloading of indexers permits a class, struct, or interface to declare multiple indexers, provided their signatures are unique within that class, struct, or interface. </list_item><list_item> Overloading of operators permits a class or struct to declare multiple operators with the same name, provided their signatures are unique within that class or struct. </list_item></list></paragraph>
<paragraph>
<example>[Example: The following example shows a set of overloaded method declarations along with their signatures. <code_example><![CDATA[
interface ITest
{
void F(); // F()
void F(int x); // F(int)
void F(ref int x); // F(ref int)
void F(out int x); // F(out int)
void F(int x, int y); // F(int, int)
int F(string s); // F(string)
int F(int x); // F(int) error
void F(string[] a); // F(string[])
void F(params string[] a); // F(string[]) error
}
]]></code_example></example>
</paragraph>
<paragraph>
<example>Note that any ref and out parameter modifiers (<hyperlink>17.5.1</hyperlink>) are part of a signature. Thus, F(<keyword>int</keyword>), F(ref <keyword>int</keyword>), and F(out <keyword>int</keyword>) are all unique signatures. Also, note that the return type and the params modifier are not part of a signature, so it is not possible to overload solely based on return type or on the inclusion or exclusion of the params modifier. As such, the declarations of the methods F(<keyword>int</keyword>) and F(params string[]) identified above, result in a compile-time error. end example]</example>
</paragraph>
</clause>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<clause number="10.7.1.1" title="Hiding through nesting">
<paragraph>Name hiding through nesting can occur as a result of nesting namespaces or types within namespaces, as a result of nesting types within classes or structs, and as a result of parameter and local variable declarations. </paragraph>
<paragraph>
<example>[Example: In the example <code_example><![CDATA[
class A
{
int i = 0;
void F() {
int i = 1;
}
void G() {
i = 1;
}
}
]]></code_example>within the F method, the instance variable i is hidden by the local variable i, but within the G method, i still refers to the instance variable. end example]</example>
</paragraph>
<paragraph>When a name in an inner scope hides a name in an outer scope, it hides all overloaded occurrences of that name. <example>[Example: In the example <code_example><![CDATA[
class Outer
{
static void F(int i) {}
static void F(string s) {}
class Inner
{
void G() {
F(1); // Invokes Outer.Inner.F
F("Hello"); // Error
}
static void F(long l) {}
}
}
]]></code_example>the call F(1) invokes the F declared in Inner because all outer occurrences of F are hidden by the inner declaration. For the same reason, the call F(&quot;Hello&quot;) results in a compile-time error. end example]</example> </paragraph>
</clause>

Some files were not shown because too many files have changed in this diff Show More