Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Method overloading

Fully qualified name | Access to private and protected members of the containing type | Reserved member names | Static and instance fields | Volatile fields | Static field initialization | Method parameters | Parameter arrays | Virtual methods | Override methods |


Читайте также:
  1. Acceptance sampling is a method of measuring random samples of lots or batches of products against predetermined standards. (Acceptance sampling, moderate)
  2. After method: an introduction
  3. Alternative Methods
  4. Be methodical
  5. Calculation Method for a Full-Period Consecutive Sampling
  6. CHAPTER IV. METHODICISM
  7. Characterization methods and instruments

The method overload resolution rules are described in §7.5.2.

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

member-name:
identifier
interface-type. identifier

A property-declaration may include a set of attributes (§17) and a valid combination of the four access modifiers (§10.3.5), the new (§10.3.4), static (§10.6.2), virtual (§10.6.3), override (§10.6.4), sealed (§10.6.5), abstract (§10.6.6), and extern (§10.6.7) modifiers.

Property declarations are subject to the same rules as method declarations (§10.6) with regard to valid combinations of modifiers.

The type of a property declaration specifies the type of the property introduced by the declaration, and the member-name specifies the name of the property. Unless the property is an explicit interface member implementation, the member-name is simply an identifier. For an explicit interface member implementation (§13.4.1), the member-name consists of an interface-type followed by a “.” and an identifier.

The type of a property must be at least as accessible as the property itself (§3.5.4).

The accessor-declarations, which must be enclosed in “{” and “}” tokens, declare the accessors (§10.7.2) of the property. The accessors specify the executable statements associated with reading and writing the property.

Even though the syntax for accessing a property is the same as that for a field, a property is not classified as a variable. Thus, it is not possible to pass a property as a ref or out argument.

When a property declaration includes an extern modifier, the property is said to be an external property. Because an external property declaration provides no actual implementation, each of its accessor-declarations consists of a semicolon.


Дата добавления: 2015-11-16; просмотров: 57 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
Extension methods| Static and instance properties

mybiblioteka.su - 2015-2024 год. (0.005 сек.)