C# 0 The Complete Reference


PART I C h a p t e r   7



Download 4,07 Mb.
Pdf ko'rish
bet217/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   213   214   215   216   217   218   219   220   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART I

C h a p t e r   7 :  

A r r a y s   a n d   S t r i n g s  

153


PART IPART I

foreach(


type loopvar

 in 


collection

)

statement

;

Here, 


type loopvar

 specifies the type and name of an 



iteration variable.

 The iteration variable 

receives the value of the next element in the collection each time the 

foreach

 loop iterates. 

The collection being cycled through is specified by 

collection,

 which, for the rest of this 

discussion, is an array. Thus, 

type

 must be the same as (or compatible with) the element 

type of the array. Beginning with C# 3.0, 

type

 can also be 



var

, in which case the compiler 

determines the type based on the element type of the array. This can be useful when 

working with certain queries, as described later in this book. Normally, you will explicitly 

specify the type.

Here is how 



foreach

 works. When the loop begins, the first element in the array is 

obtained and assigned to 

loopvar.

 Each subsequent iteration obtains the next element from 

the array and stores it in 

loopvar.

 The loop ends when there are no more elements to obtain. 

Thus, the 


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   213   214   215   216   217   218   219   220   ...   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