C# 0 The Complete Reference


join . Recall that in the previous version, a class called  Temp



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

join

. Recall that in the previous version, a class called 



Temp

was needed to encapsulate the result of the 



join

. Through the use of an anonymous type, 

this “placeholder” class is no longer needed and no longer clutters the source code to the 

program. The output from the program is unchanged from before.

// Use an anonymous type to improve the join demo program.

using System;

using System.Linq;

// A class that links an item name with its number.

class Item {

  public string Name { get; set; }

  public int ItemNumber { get; set; }

  public Item(string n, int inum) {

    Name = n;

    ItemNumber = inum;

  }

}

// A class that links an item number with its in-stock status.



class InStockStatus {

  public int ItemNumber { get; set; }

  public bool InStock { get; set; }

  public InStockStatus(int n, bool b) {

    ItemNumber = n;

    InStock = b;

  }

}

class AnonTypeDemo {



  static void Main() {

    Item[] items = {

         new Item("Pliers", 1424),

         new Item("Hammer", 7892),

         new Item("Wrench", 8534),

         new Item("Saw", 6411)

    };

    InStockStatus[] statusList = {



         new InStockStatus(1424, true),

         new InStockStatus(7892, false),

         new InStockStatus(8534, true),

         new InStockStatus(6411, true)

    };

www.freepdf-books.com




Download 4,07 Mb.

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