C# 0 The Complete Reference


PART II C h a p t e r   2 4



Download 4,07 Mb.
Pdf ko'rish
bet1007/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   1003   1004   1005   1006   1007   1008   1009   1010   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART II

C h a p t e r   2 4 :  

C o l l e c t i o n s ,   E n u m e r a t o r s ,   a n d   I t e r a t o r s    

813


Using Iterators

As the preceding example shows, it is not difficult to implement 



IEnumerator

 and 


IEnumerable

. However, it can be made even easier through the use of an 



iterator.

 An iterator 

is a method, operator, or accessor that returns the members of a set of objects, one member at 

a time, from start to finish. For example, assuming some array that has five elements, then an 

iterator for that array will return those five elements, one at a time. By implementing an 

iterator, you make it possible for an object of a class to be used in a 



foreach

 loop.


Let’s begin with an example of a simple iterator. The following program is a modified 

version of the preceding program that uses an iterator rather than explicitly implementing 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   1003   1004   1005   1006   1007   1008   1009   1010   ...   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