C# 0 The Complete Reference


PART I C h a p t e r   8



Download 4,07 Mb.
Pdf ko'rish
bet264/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   260   261   262   263   264   265   266   267   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART I

C h a p t e r   8 :  

A   C l o s e r   L o o k   a t   M e t h o d s   a n d   C l a s s e s  

193


PART IPART I

Although


ref

 and 


out

 participate in overload resolution, the difference between the two 

alone is not sufficient. For example, these two versions of 

MyMeth( )

 are invalid:

// Wrong!

public void MyMeth(out int x) { // ...

public void MyMeth(ref int x) { // ...

In this case, the compiler cannot differentiate between the two version of 



MyMeth( )

 simply 


because one uses an 

out int

 parameter and the other uses a 



ref int

 parameter.

Method overloading supports polymorphism because it is one way that C# 

implements the “one interface, multiple methods” paradigm. To understand how, 

consider the following. In languages that do not support method overloading, each 

method must be given a unique name. However, frequently you will want to implement 

essentially the same method for different types of data. Consider the absolute value 

function. In languages that do not support overloading, there are usually three or more 

versions of this function, each with a slightly different name. For instance, in C, the 

function



Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   260   261   262   263   264   265   266   267   ...   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