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

Classes in C#

Прочитайте:
  1. Classes of Supply
  2. Classes' data members in C#.
  3. Classes' function members in C#.
  4. Creating generic classes in C#.
  5. Extinction of Different Classes of Fires
  6. NET framework classes.
  7. Partial classes in C#.
  8. When creating generic classes, you might need some more C# keywords.

Def: Classes are essentially templates from which you can create objects. Each object contains data and has methods to manipulate and access that data. The class defines what data and functionality each particular object (called an instance) of that class can contain.

For example, if you have a class that represents a customer, it might define fields such as CustomerID, FirstName, LastName, and Address, which you will use to hold information about a particular customer. It might also define functionality that acts upon the data stored in these fields. You can then instantiate an object of this class to represent one specific customer, set the field values for that instance, and use its functionality.

class PhoneCustomer{

public const string DayOfSendingBill = "Monday";

public int CustomerID;

public string FirstName;

public string LastName;}

Desc: For classes, you use the keyword new to declare an instance. This keyword creates the object and initializes it; in the following example, the default behavior is to zero out its fields:

PhoneCustomer myCustomer = new PhoneCustomer(); // works for a class

The data and functions within a class are known as the class’s members. Microsoft’s official terminology distinguishes between data members and function members. In addition to these members, classes can

contain nested types (such as other classes). Accessibility to the members can be public, protected, internal protected, private, or internal.

 

 


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



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.003 сек.)