C# 0 The Complete Reference


PART I C h a p t e r   5



Download 4,07 Mb.
Pdf ko'rish
bet160/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   156   157   158   159   160   161   162   163   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART I

C h a p t e r   5 :  

P r o g r a m   C o n t r o l   S t a t e m e n t s  

105


PART IPART I

// Use continue.

using System;

class ContDemo {

  static void Main() {

    // Print even numbers between 0 and 100.

    for(int i = 0; i <= 100; i++) {

      if((i%2) != 0) continue; // iterate

      Console.WriteLine(i);

    }


  }

}

Only even numbers are printed, because an odd number will cause the loop to iterate early



bypassing the call to 

WriteLine( )

.

In



while

 and 


do-while

 loops, a 



continue

 statement will cause control to go directly to 

the conditional expression and then continue the looping process. In the case of the 

for

, the 


iteration expression of the loop is evaluated, then the conditional expression is executed, 

and then the loop continues.

Good uses of 

continue

 are rare. One reason is that C# provides a rich set of loop statements 

that fit most applications. However, for those special circumstances in which early iteration 

is needed, the 



continue

 statement provides a structured way to accomplish it.




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   156   157   158   159   160   161   162   163   ...   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