This print for content only-size & color not accurate 7" X 9-1/4" / casebound / malloy


// Map set of anonymous objects to an Array object



Download 21,46 Mb.
Pdf ko'rish
bet927/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   923   924   925   926   927   928   929   930   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

// Map set of anonymous objects to an Array object.

// Here were are relying on type inference of the generic

// type parameter, as we don't know the type of type!

return makesColors.ToArray();

}

we could invoke and process the data from Main() as follows:



Array objs = GetProjectedSubset();

foreach (object o in objs)

{

Console.WriteLine(o);  // Calls ToString() on each anonymous object.



}

Note that we have to use a literal System.Array object and cannot make use of the C# array

declaration syntax, given that we don’t know the underlying type of type! Also note that we are not

specifying the type parameter to the generic ToArray() method, as we (once again) don’t know

the underlying data type until compile time (which is too late for our purposes).

The obvious problem is that we lose any strong typing, as each item in the Array object is

assumed to be of type Object. Nevertheless, when you need to return a LINQ result set which is the

result of a projection operation, transforming the data into an Array type (or another suitable con-

tainer via other members of the Enumerable type) is mandatory.


Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   923   924   925   926   927   928   929   930   ...   1830




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