The Role of ICollection
The ICollection interface is the most primitive interface of the System.Collections namespace in
that it defines a behavior supported by a collection type. In a nutshell, this interface provides a
small set of members that allow you to determine (a) the number of items in the container, (b) the
thread safety of the container, as well as (c) the ability to copy the contents into a System.Array type.
Formally, ICollection is defined as follows (note that ICollection extends IEnumerable):
public interface ICollection : IEnumerable
{
int Count { get; }
bool IsSynchronized { get; }
object SyncRoot { get; }
void CopyTo(Array array, int index);
}
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
310
8849CH10.qxd 9/25/07 4:17 PM Page 310
Do'stlaringiz bilan baham: |