C# 0 The Complete Reference


PART I C h a p t e r   6



Download 4,07 Mb.
Pdf ko'rish
bet164/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   160   161   162   163   164   165   166   167   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART I

C h a p t e r   6 :  

I n t r o d u c i n g   C l a s s e s   a n d   O b j e c t s  

111


PART IPART I

items of information about a building: the number of floors, the total area, and the number 

of occupants.

The first version of 



Building

 is shown here. It defines three instance variables: 



Floors

,

Area

, and 

Occupants

. Notice that 



Building

 does not contain any methods. Thus, it is 

currently a data-only class. (Subsequent sections will add methods to it.)

class Building {

  public int Floors;    // number of floors

  public int Area;      // total square footage of building

  public int Occupants; // number of occupants

}

The instance variables defined by 



Building

 illustrate the way that instance variables are 

declared in general. The general form for declaring an instance variable is shown here:

access type var-name

;

Here, 



access

 specifies the access; 



type

 specifies the type of variable; and 



var-name

 is the 


variable’s name. Thus, aside from the access specifier, you declare an instance variable in 

the same way that you declare local variables. For 



Building

, the variables are preceded by 

the

public

 access modifier. As explained, this allows them to be accessed by code outside 

of


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   160   161   162   163   164   165   166   167   ...   1096




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish