C# 0 The Complete Reference


let  clause assigns to  chrArray



Download 4,07 Mb.
Pdf ko'rish
bet710/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   706   707   708   709   710   711   712   713   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

let

 clause assigns to 



chrArray

 a reference to the array 

returned by 

str.ToCharArray( )

:

let chrArray = str.ToCharArray()



After the 

let

 clause, other clauses can make use of 



chrArray

. Furthermore, because all arrays 

in C# are convertible to 

IEnumerable

,

chrArray

 can be used as a data source for a second, 

nested


from

 clause. This is what happens in the example. It uses the nested 



from

 to enumerate 

the individual characters in the array, sorting them into ascending sequence and returning 

the result.

You can also use a 

let

 clause to hold a non-enumerable value. For example, the following 

is a more efficient way to write the query used in the 

IntoDemo

 program shown in the 

preceding section.

var webAddrs = from addr in websites

               let idx = addr.LastIndexOf(".")

               where idx != -1

               group addr by addr.Substring(idx)

                          into ws

               where ws.Count() > 2

               select ws;

In this version, the index of the last occurrence of a period is assigned to 

idx

. This value 

is then used by 

Substring( )

. This prevents the search for the period from having to be 

conducted twice.


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   706   707   708   709   710   711   712   713   ...   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