C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet967/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   963   964   965   966   967   968   969   970   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

The Generic Interfaces

System.Collections.Generic

 defines a number of generic interfaces, all of which parallel 

their corresponding non-generic counterparts. The generic interfaces are summarized in 

Table 24-10.



The ICollection Interface

The


ICollection

 interface defines those features that all generic collections have in 

common. It inherits the 

IEnumerable

 and 


IEnumerable

 interfaces. 



ICollection

 is 


the generic version of the non-generic 

ICollection

 interface. However, there are some 

differences between the two.

ICollection

 defines the following properties:

int Count { get; }

bool IsReadOnly { get; }



Count

 contains the number of items currently held in the collection. 



IsReadOnly

 is true if 

the collection is read-only. It is false if the collection is read/write.

Interface

Description

ICollection

Defines the foundational features for the generic collections.

IComparer

Defines the generic 

Compare( )

 method that per forms a 

comparison on objects stored in a collection.

IDictionar y

Defines a generic collection that consists of key/value pairs. 

IEnumerable

Defines the generic 

GetEnumerator( )

 method, which supplies the 

enumerator for a collection class.

IEnumerator

Provides members that enable the contents of a collection to be 

obtained one at a time.

IEqualityComparer

Compares two objects for equality. 

IList

Defines a generic collection that can be accessed via an indexer.

T

ABLE


 24-10 

The Generic Collection Inter faces

www.freepdf-books.com



776

 

P a r t   I I :  



E x p l o r i n g   t h e   C #   L i b r a r y

ICollection

 defines the following methods. Notice it defines a few more methods 

than does its non-generic counterpart.

Method


Description

void Add(T 



obj

)

Adds 



obj

 to the invoking collection. Throws a 

NotSupportedException

 if the collection is read-only.

void Clear( )

Deletes all elements from the invoking collection and 

sets

Count


 to zero.

bool Contains(T 



obj

)

Returns true if the invoking collection contains the 



object passed in 

obj

 and false other wise.

void CopyTo(T[ ] 

target

, int 


star tIdx

)

Copies the contents of the invoking collection to 



the array specified by 

target,

 beginning at the index 

specified by 

star tIdx.

bool Remove(T 



obj

)

Removes the first occurrence of 



obj

 from the invoking 

collection. Returns true if 

obj

 was removed and false if 

it was not found in the invoking collection.

Several of these methods will throw 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   963   964   965   966   967   968   969   970   ...   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