C# 0 The Complete Reference


select . It creates a class called  EmailAddress



Download 4,07 Mb.
Pdf ko'rish
bet698/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   694   695   696   697   698   699   700   701   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

select

. It creates a class called 



EmailAddress

 that contains two properties. The first holds a person’s name. The second 

contains an e-mail address. The program then creates an array that contains several 

EmailAddress

 entries. The program uses a query to obtain a list of just the e-mail addresses 

by themselves.

// Return a portion of the range variable.

using System;

using System.Linq;

class EmailAddress {

  public string Name { get; set; }

  public string Address { get; set; }

  public EmailAddress(string n, string a) {

    Name = n;

    Address = a;

  }

}

www.freepdf-books.com




558

 

P a r t   I :  



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

class SelectDemo2 {

  static void Main() {

    EmailAddress[] addrs = {

         new EmailAddress("Herb", "Herb@HerbSchildt.com"),

         new EmailAddress("Tom", "Tom@HerbSchildt.com"),

         new EmailAddress("Sara", "Sara@HerbSchildt.com")

    };


    // Create a query that selects e-mail addresses.

    var eAddrs = from entry in addrs

                 select entry.Address;

    Console.WriteLine("The e-mail addresses are");

    // Execute the query and display the results.

    foreach(string s in eAddrs) Console.WriteLine("  " + s);

  }

}

The output is shown here:



The e-mail addresses are

  Herb@HerbSchildt.com

  Tom@HerbSchildt.com

  Sara@HerbSchildt.com

Pay special attention to the 


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   694   695   696   697   698   699   700   701   ...   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