X hits on this document

998 views

0 shares

0 downloads

0 comments

229 / 396

C# LANGUAGE SPECIFICATION

class A { int x = 1; int y = x + 1;// Error, reference to instance member of this }

the variable initializer for y results in a compile-time error because it references a member of the instance being created.

10.5 Methods

A method is a member that implements a computation or action that can be performed by an object or class. Methods are declared using method-declarations:

method-declaration: method-header   method-body

method-header: attributesopt   method-modifiersopt   return-type   member-name   (   formal-parameter-listopt   )

method-modifiers: method-modifier method-modifiers   method-modifier

method-modifier: new public protected internal private static virtual sealed override abstract extern

return-type: type void

member-name: identifier interface-type   .   identifier

method-body: block ;

A method-declaration may include a set of attributes (§‎17) and a valid combination of the four access modifiers (§‎10.2.3), the new (§‎10.2.2),  static (§‎10.5.2), virtual (§‎10.5.3), override (§‎10.5.4), sealed (§‎10.5.5), abstract (§‎10.5.6), and extern (§‎10.5.7) modifiers.

A declaration has a valid combination of modifiers if all of the following are true:

The declaration includes a valid combination of access modifiers (§‎10.2.3).

The declaration does not include the same modifier multiple times.

216Copyright Microsoft Corporation 1999-2003. All Rights Reserved.

Document info
Document views998
Page views998
Page last viewedFri Dec 09 10:36:01 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments