C# 0 The Complete Reference


ref : An argument passed by  ref



Download 4,07 Mb.
Pdf ko'rish
bet248/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   244   245   246   247   248   249   250   251   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

ref

: An argument passed by 



ref

 must 


be assigned a value prior to the call. The reason is that the method that receives such an 

argument assumes that the parameter refers to a valid value. Thus, using 



ref

, you cannot 

use a method to give an argument an initial value.

Use out

Sometimes you will want to use a reference parameter to receive a value from a method, but 

not pass in a value. For example, you might have a method that performs some function, 

such as opening a network socket, that returns a success/fail code in a reference parameter. 

In this case, there is no information to pass into the method, but there is information to pass 

back out. The problem with this scenario is that a 



ref

 parameter must be initialized to a 

value prior to the call. Thus, to use a 

ref

 parameter would require giving the argument a 

dummy value just to satisfy this constraint. Fortunately, C# provides a better alternative: 

the



Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   244   245   246   247   248   249   250   251   ...   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