X hits on this document

926 views

0 shares

0 downloads

0 comments

243 / 396

C# LANGUAGE SPECIFICATION

class A { public int F() {}// Error, return value required

public int G() { return 1; }

public int H(bool b) { if (b) { return 1; } else { return 0; } } }

the value-returning F method results in a compile-time error because control can flow off the end of the method body. The G and H methods are correct because all possible execution paths end in a return statement that specifies a return value.

10.5.9 Method overloading

The method overload resolution rules are described in §‎7.4.2.

10.6 Properties

A property is a member that provides access to a characteristic of an object or a class. Examples of properties include the length of a string, the size of a font, the caption of a window, the name of a customer, and so on. Properties are a natural extension of fields—both are named members with associated types, and the syntax for accessing fields and properties is the same. However, unlike fields, properties do not denote storage locations. Instead, properties have accessors that specify the statements to be executed when their values are read or written. Properties thus provide a mechanism for associating actions with the reading and writing of an object’s attributes; furthermore, they permit such attributes to be computed.

Properties are declared using property-declarations:

property-declaration: attributesopt   property-modifiersopt   type   member-name   {   accessor-declarations   }

property-modifiers: property-modifier property-modifiers   property-modifier

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

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

Document info
Document views926
Page views926
Page last viewedWed Dec 07 15:09:37 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments