C# 0 The Complete Reference


Name  and  InStock



Download 4,07 Mb.
Pdf ko'rish
bet718/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   714   715   716   717   718   719   720   721   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

Name

 and 


InStock

. These are given the values specified by the item’s name and availability. Because 

of the anonymous type, there is no longer any need for the 

Temp

 class.


One other point. Notice the 

foreach

 loop that executes the query. It now uses 



var

 to 


declare the iteration variable. This is necessary because the type of the object contained in 

inStockList

 has no name. This situation is one of the reasons that C# 3.0 added implicitly 

typed variables. They are needed to support anonymous types.

Before moving on, there is one more aspect of anonymous types that warrants a mention. 

In some cases, including the one just shown, you can simplify the syntax of the anonymous 

type through the use of a 



projection initializer.

 In this case, you simply specify the name of 

the initializer by itself. This name automatically becomes the name of the property. For 

example, here is another way to code the 



select

 clause used by the preceding program:

select new { item.Name, entry.InStock };

Here, the property names are still 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   714   715   716   717   718   719   720   721   ...   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