C# 0 The Complete Reference


Building  and  BuildingDemo



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

Building

 and 


BuildingDemo

. Inside 



BuildingDemo

,

the



Main( )

 method creates an instance of 



Building

 called 


house

. Then the code within 



Main( )

 accesses the instance variables associated with 



house

, assigning them values and 

using those values. It is important to understand that 

Building

 and 


BuildingDemo

 are two 

separate classes. The only relationship they have to each other is that one class creates an 

instance of the other. Although they are separate classes, code inside 



BuildingDemo

 can 


access the members of 

Building

 because they are declared 



public

. If they had not been 

given the 

public

 access specifier, their access would have been limited to the 



Building

class, and 



BuildingDemo

 would not have been able to use them.

Assume that you call the preceding file 

UseBuilding.cs

. Compiling this program creates 

a file called 

UseBuilding.exe

. Both the 



Building

 and 


BuildingDemo

 classes are automatically 

part of the executable file. The program displays the following output:

house has:

  2 floors

  4 occupants

  2500 total area

  625 area per person

It is not necessary for the 

Building

 and the 



BuildingDemo

 classes to actually be in 

the same source file. You could put each class in its own file, called 

Building.cs

 and 


BuildingDemo.cs

, for example. Just tell the C# compiler to compile both files and link 

www.freepdf-books.com



Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   163   164   165   166   167   168   169   170   ...   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