C# 0 The Complete Reference


nums . It does this by use of the  Where( )



Download 4,07 Mb.
Pdf ko'rish
bet725/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   721   722   723   724   725   726   727   728   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

nums

.

It does this by use of the 



Where( ) 

method (to filter the values) and 



Select( )

 (to select the 

www.freepdf-books.com



576

 

P a r t   I :  



T h e   C #   L a n g u a g e

values). The 



Where( )

 method can be invoked on 



nums

 because all arrays implement 



IEnumerable

, which supports the query extension methods.

Technically, the 

Select( )

 method in the preceding example is not necessary because in 

this simple case, the sequence returned by 

Where( )

 already contains the result. However, 

you can use more sophisticated selection criteria, just as you did with the query syntax. For 

example, this query returns the positive values in 



nums

 increased by an order of magnitude:

var posNums = nums.Where(n => n > 0).Select(r => r * 10);

As you might expect, you can chain together other operations. For example, this query 

selects the positive values, sorts them into descending order, and returns the resulting 

sequence:

var posNums = nums.Where(n => n > 0).OrderByDescending(j => j);

Here, the expression 



j => j

 specifies that the ordering is dependent on the input parameter, 

which is an element from the sequence obtained from 

Where( )

.

Here is an example that demonstrates the 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   721   722   723   724   725   726   727   728   ...   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