CVB.Net 14.0
ReadOnlyCollection< T > Class Template Reference

Read-only, generic collection of elements. More...

Inherits ICollection< T >.

Public Member Functions

 ReadOnlyCollection (ICollection< T > collection)
 Creates a new ReadOnlyCollection wrapping the given collection . More...
 
bool Contains (T item)
 Determines whether the item is in this collection. More...
 
void CopyTo (T[] array, int arrayIndex)
 Copies the entire collection to a compatible one-dimensional array , starting at the specified arrayIndex . More...
 
IEnumerator< T > GetEnumerator ()
 Returns an enumerator that iterates through this collection. More...
 

Properties

ICollection< T > Items [get]
 Gets the collection this ReadOnlyCollection wraps.
 
int Count [get]
 Gets the number of items in this collection.
 

Detailed Description

Read-only, generic collection of elements.

This class wraps another collection as a read-only view on it.

This implementation is needed as this is only present in .Net 4.5 and above.

Template Parameters
TType of elements in this collection.

Constructor & Destructor Documentation

◆ ReadOnlyCollection()

ReadOnlyCollection ( ICollection< T >  collection)

Creates a new ReadOnlyCollection wrapping the given collection .

Parameters
collectionCollection to wrap.
Exceptions
ArgumentNullExceptioncollection is null.

Member Function Documentation

◆ Contains()

bool Contains ( item)

Determines whether the item is in this collection.

Parameters
itemItem to locate; may be null.
Returns
true if item could be located; false if not.

◆ CopyTo()

void CopyTo ( T[]  array,
int  arrayIndex 
)

Copies the entire collection to a compatible one-dimensional array , starting at the specified arrayIndex .

Parameters
arrayDestination array.
arrayIndexZero-based index at which copying begins.
Exceptions
ArgumentNullExceptionarray is null.
ArgumentOutOfRangeExceptionarrayIndex is less than zero.
ArgumentExceptionThe number of elements in this collection is greater than the available space in array .

◆ GetEnumerator()

IEnumerator< T > GetEnumerator ( )

Returns an enumerator that iterates through this collection.

Returns
Enumerator object.