IReadOnlyList<T>
Low version of IList<T> which provides only readonly view of list.
public interface IReadOnlyList<out T> : IEnumerable<T>, IEnumerable { int Count { get; } T this[int index] { get; } }
Low version of IList<T> which provides only readonly view of list.
public interface IReadOnlyList<out T> : IEnumerable<T>, IEnumerable { int Count { get; } T this[int index] { get; } }
Standard interface for collection indexable by position.
Functionality inherited from ICollection<T> and IEnumerable<T>.
Provides the ability to read or write an element by position.
public interface IList: ICollection , IEnumerable , IEnumerable { T this [int index] { get; set; } int IndexOf (T item); void Insert (int index, T item); void RemoveAt (int index); }
IndexOf – performs liner search, returns -1 if item not found.
Insert – inserts at specified index.
RemoveAt – removes at specified index.
public interface IList : ICollection, IEnumerable { object this [int index] { get; set } bool IsFixedSize { get; } bool IsReadOnly { get; } int Add (object value); void Clear(); bool Contains (object value); int IndexOf (object value); void Insert (int index, object value); void Remove (object value); void RemoveAt (int index); }
Add – returns an integer index of the newly added item.
ICollection<T> is the standard interface for countable collections of objects.
It provides the ability to determine the size of a collection (Count).
If the collection is writable you can also Add, Remove and Clear items from the collection.
Collection can be traversed via foreach statement since it extends IEnumerable
Methods and Properties
Contains – determine whether an item exists in the collection.
ToArray – copy the collection into an array.
IsReadOnly – determine whether the collection is read-only.
Count-size of the collection.
Add– add item to the collection.
Remove– remove item from collection.
Clear– clear collection.
Generic Collection
public interface ICollection<T> : IEnumerable<T>, IEnumerable { int Count { get; } bool Contains (T item); void CopyTo (T[] array, int arrayIndex); bool IsReadOnly { get; } void Add(T item); bool Remove (T item); void Clear(); }
Non Generic Collection
public interface ICollection : IEnumerable { int Count { get; } bool IsSynchronized { get; } object SyncRoot { get; } void CopyTo (Array array, int index); }
The interface is implemented in conjunction with either IList or IDictionary.