C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet313/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   309   310   311   312   313   314   315   316   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

&

 and 


|

 are implemented. They are shown here:

// Overload | for short-circuit evaluation.

public static ThreeD operator |(ThreeD op1, ThreeD op2)

{

  if( ((op1.x != 0) || (op1.y != 0) || (op1.z != 0)) |



     ((op2.x != 0) || (op2.y != 0) || (op2.z != 0)) )

    return new ThreeD(1, 1, 1);

  else

    return new ThreeD(0, 0, 0);



}

// Overload & for short-circuit evaluation.

public static ThreeD operator &(ThreeD op1, ThreeD op2)

{

  if( ((op1.x != 0) && (op1.y != 0) && (op1.z != 0)) &



     ((op2.x != 0) && (op2.y != 0) && (op2.z != 0)) )

    return new ThreeD(1, 1, 1);

  else

    return new ThreeD(0, 0, 0);



}

Notice first that both now return an object of type 



ThreeD

. Pay attention to how this object 

is generated. If the outcome of the operation is true, then a true 

ThreeD

 object (one in which 

at least one coordinate is non-zero) is created and returned. If the outcome is false, then a 

false object is created and returned. Thus, in a statement like this

if(a & b) Console.WriteLine("a & b is true.");

else Console.WriteLine("a & b is false.");

the outcome of 


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   309   310   311   312   313   314   315   316   ...   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