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


// Create a List containing integers



Download 21,46 Mb.
Pdf ko'rish
bet649/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   645   646   647   648   649   650   651   652   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

// Create a List containing integers.

List myInts = new List();



// Create a List containing SportsCar objects.

List myCars = new List();



// Create a List containing Person objects.

List
myPeople = new List


();

}

At this point, you might wonder what exactly becomes of the specified placeholder value. If you



were to make use of the Visual Studio 2008 Code Definition window (see Chapter 2), you will find

that the placeholder T is used throughout the definition of the List type. Here is a partial listing

(note the items in bold):

// A partial listing of the List type.

namespace System.Collections.Generic

{

public class List<T> :



IList<T>, ICollection<T>, IEnumerable<T>,

IList, ICollection, IEnumerable

{

...


public void Add(item);

C H A P T E R   1 0  



C O L L E C T I O N S   A N D   G E N E R I C S



325

8849CH10.qxd  9/25/07  4:17 PM  Page 325




public IList<T> AsReadOnly();

public int BinarySearch(item);

public bool Contains(item);

public void CopyTo(T[] array);

public int FindIndex(System.Predicate<T> match);

public FindLast(System.Predicate<T> match);

public bool Remove(item);

public int RemoveAll(System.Predicate<T> match);

public T[] ToArray();

public bool TrueForAll(System.Predicate<T> match);

public this[int index] { get; set; }

}

}



When you create a List specifying SportsCar types, it is as if the List type were really

defined as follows:

namespace System.Collections.Generic

{

public class List<SportsCar> :



IList<SportsCar>, ICollection<SportsCar>, IEnumerable<SportsCar>,

IList, ICollection, IEnumerable

{

...


public void Add(SportsCar item);

public IList<SportsCar> AsReadOnly();

public int BinarySearch(SportsCar item);

public bool Contains(SportsCar item);

public void CopyTo(SportsCar[] array);

public int FindIndex(System.Predicate<SportsCar> match);

public SportsCar FindLast(System.Predicate<SportsCar> match);

public bool Remove(SportsCar item);

public int RemoveAll(System.Predicate<SportsCar> match);

public SportsCar [] ToArray();

public bool TrueForAll(System.Predicate<SportsCar> match);

public SportsCar this[int index] { get; set; }

}

}

Of course, when you create a generic List, the compiler does not literally create a brand-



new implementation of the List type. Rather, it will address only the members of the generic

type you actually invoke. To solidify this point, assume you exercise a List of SportsCar objects

as follows:

static void Main(string[] args)

{


Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   645   646   647   648   649   650   651   652   ...   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