13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>C#</strong> LANGUAGE SPECIFICATION• If the declaration includes the sealed modifier, then the declaration also includes the override modifier.The return-type of a method declaration specifies the type of the value computed and returned by the method.The return-type is void if the method does not return a value.The member-name specifies the name of the method. Unless the method is an explicit interface memberimplementation (§20.4.1), the member-name is simply an identifier. For an explicit interface memberimplementation, the member-name consists of an interface-type followed by a “.” and an identifier.The optional formal-parameter-list specifies the parameters of the method (§17.5.1).The return-type and each of the types referenced in the formal-parameter-list of a method must be at least asaccessible as the method itself (§10.5.4).For abstract and extern methods, the method-body consists simply of a semicolon. For all other methods, themethod-body consists of a block, which specifies the statements to execute when the method is invoked.The name and the formal parameter list of a method define the signature (§10.6) of the method. Specifically, thesignature of a method consists of its name and the number, modifiers, and types of its formal parameters. Thereturn type is not part of a method’s signature, nor are the names of the formal parameters.The name of a method must differ from the names of all other non-methods declared in the same class. Inaddition, the signature of a method must differ from the signatures of all other methods declared in the sameclass, and two methods declared in the same class may not have signatures that differ solely by ref and out.17.5.1 Method parametersThe parameters of a method, if any, are declared by the method’s formal-parameter-list.formal-parameter-list:fixed-parametersfixed-parameters , parameter-arrayparameter-arrayfixed-parameters:fixed-parameterfixed-parameters , fixed-parameterfixed-parameter:attributes opt parameter-modifier opt type identifierparameter-modifier:refoutparameter-array:attributes opt params array-type identifierThe formal parameter list consists of one or more comma-separated parameters of which only the last may be aparameter-array.A fixed-parameter consists of an optional set of attributes (§24), an optional ref or out modifier, a type, and anidentifier. Each fixed-parameter declares a parameter of the given type with the given name.A parameter-array consists of an optional set of attributes (§24), a params modifier, an array-type, and anidentifier. A parameter array declares a single parameter of the given array type with the given name. The arraytypeof a parameter array must be a single-dimensional array type (§19.1). In a method invocation, a parameterarray permits either a single argument of the given array type to be specified, or it permits zero or morearguments of the array element type to be specified. Parameter arrays are described further in §17.5.1.4.A method declaration creates a separate declaration space for parameters and local variables. Names areintroduced into this declaration space by the formal parameter list of the method and by local variabledeclarations in the block of the method. All names in the declaration space of a method must be unique;otherwise, a compile-time error results.228

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

Saved successfully!

Ooh no, something went wrong!