This print for content only-size & color not accurate 7" X 9-1/4" / casebound / malloy



Download 21,46 Mb.
Pdf ko'rish
bet769/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   765   766   767   768   769   770   771   772   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition



Note

In C#,


true

and 


false

can be used as operators in addition to literals. This functionality can be useful

when building custom types that represent true, false, and null (meaning neither true nor false).

Overloading Binary Operators

To illustrate the process of overloading binary operators, assume the following simple Point struc-

ture defined in a new Console Application named OverloadedOps:

// Just a simple everyday C# struct.

public struct Point

{

private int x, y;



public Point(int xPos, int yPos)

{

x = xPos;



y = yPos;

}

public override string ToString()



{

return string.Format("[{0}, {1}]", this.x, this.y);

}

}

C H A P T E R   1 2  



I N D E X E R S, O P E R ATO R S, A N D   P O I N T E R S



389

8849CH12.qxd  9/26/07  11:31 AM  Page 389




Now, logically speaking, it makes sense to add Points together. For example, if you added

together two Point variables, you should receive a new Point that is the summation of the x and y

values. On a related note, it may be helpful to subtract one Point from another. Ideally, you would

like to be able to author the following code:




Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   765   766   767   768   769   770   771   772   ...   1830




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