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.

Chapter 17 Classesthe variable initializer for y results in a compile-time error because it references a member of the instance beingcreated. end example]17.5 MethodsA 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-bodymethod-header:attributes opt method-modifiers opt return-type member-name ( formal-parameter-list opt )method-modifiers:method-modifiermethod-modifiers method-modifiermethod-modifier:newpublicprotectedinternalprivatestaticvirtualsealedoverrideabstractexternreturn-type:typevoidmember-name:identifierinterface-type . identifiermethod-body:block;A method-declaration may include a set of attributes (§24) and a valid combination of the four access modifiers(§17.2.3), the new (§17.2.2), static (§17.5.2), virtual (§17.5.3), override (§17.5.4), sealed (§17.5.5),abstract (§17.5.6), and extern (§17.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 (§17.2.3).• The declaration does not include the same modifier multiple times.• The declaration includes at most one of the following modifiers: static, virtual, and override.• The declaration includes at most one of the following modifiers: new and override.• If the declaration includes the abstract modifier, then the declaration does not include any of the followingmodifiers: static, virtual, sealed, or extern.• If the declaration includes the private modifier, then the declaration does not include any of the followingmodifiers: virtual, override, or abstract.227

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

Saved successfully!

Ooh no, something went wrong!