C# 0 The Complete Reference


bool  variable  someCondition



Download 4,07 Mb.
Pdf ko'rish
bet132/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   128   129   130   131   132   133   134   135   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

bool

 variable 



someCondition

 is initialized to 



false

. Next, examine each 



if

 statement. As the comments indicate, in the first 



if

 statement, 



i

 is incremented despite the 

fact that 

someCondition

 is false. When the 



&

 is used, as it is in the first 



if

statement, the 

expression on the right side of the 

&

 is evaluated no matter what value the expression on 

the left has. However, in the second 

if

 statement, the short-circuit operator is used. In this 

case, the variable 

i

 is not incremented because the left operand, 



someCondition

, is false

which causes the expression on the right to be skipped. The lesson here is that if your code 

expects the right-hand operand of an AND or OR operation to be evaluated, then you must 

use C#’s non-short-circuit forms for these operations.

One other point: The short-circuit AND is also known as the 



conditional AND,

 and the 

short-circuit OR is also called the 

conditional OR.


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   128   129   130   131   132   133   134   135   ...   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