АкушерствоАнатомияАнестезиологияВакцинопрофилактикаВалеологияВетеринарияГигиенаЗаболеванияИммунологияКардиологияНеврологияНефрологияОнкологияОториноларингологияОфтальмологияПаразитологияПедиатрияПервая помощьПсихиатрияПульмонологияРеанимацияРевматологияСтоматологияТерапияТоксикологияТравматологияУрологияФармакологияФармацевтикаФизиотерапияФтизиатрияХирургияЭндокринологияЭпидемиология

Classes' data members in C#

Def: Data members are those members that contain the data for the class — fields, constants, and events. Data members can be static. A class member is always an instance member unless it is explicitly declared as static.

Desc: Fields are any variables associated with the class. You have already seen fields in use in the PhoneCustomerclass in the previous example.After you have instantiated a PhoneCustomer object, you can then access these fields using the Object.FieldName syntax, as shown in this example:

PhoneCustomer Customer1 = new PhoneCustomer();

Customer1.FirstName = "Simon";

Constants can be associated with classes in the same way as variables. You declare a constant using the const keyword. If it is declared as public, then it will be accessible from outside the class.

class PhoneCustomer

{

public const string DayOfSendingBill = "Monday";

public int CustomerID;

public string FirstName;

public string LastName;

}

Events are class members that allow an object to notify a caller whenever something noteworthy happens, such as a field or property of the class changing, or some form of user interaction occurring. The client can have code, known as an event handler, which reacts to the event.


Дата добавления: 2015-09-18 | Просмотры: 512 | Нарушение авторских прав



1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |



При использовании материала ссылка на сайт medlec.org обязательна! (0.005 сек.)