C# 0 The Complete Reference


static . The most common example of a  static



Download 4,07 Mb.
Pdf ko'rish
bet282/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   278   279   280   281   282   283   284   285   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

static

. The most common example of a 



static

 member is 



Main( )

, which is declared 



static

 because it must be called by the operating system when 

your program begins.

Outside the class, to use a 



static

 member, you must specify the name of its class followed 

by the dot operator. No object needs to be created. In fact, a 

static

 member cannot be accessed 

through an object reference. It must be accessed through its class name. For example, if you 

want to assign the value 10 to a 



static

 variable called 



count

 that is part of a class called 



Timer

, use this line:

Timer.count = 10;

This format is similar to that used to access normal instance variables through an object, 

except that the class name is used. A 

static

 method can be called in the same way—by use 

of the dot operator on the name of the class.

Variables declared as 



static

 are, essentially, global variables. When objects of its class are 

declared, no copy of a 

static

 variable is made. Instead, all instances of the class share the same 

www.freepdf-books.com



206

 

P a r t   I :  



T h e   C #   L a n g u a g e


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   278   279   280   281   282   283   284   285   ...   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