Show / Hide Table of Contents

    Class BaseCollection<T>

    Provides the base class for all generic collections.

    Inheritance
    Object
    BaseCollection<T>
    Implements
    IList<T>
    ICollection<T>
    IEnumerable<T>
    IEnumerable
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Nevatech.Vsb.Repository
    Assembly: Nevatech.Vsb.Repository.dll
    Syntax
    public class BaseCollection<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable
    Type Parameters
    Name Description
    T

    The type of elements in the collection.

    Constructors

    BaseCollection()

    Creates a new instance and ensures that base collection class uses generic list as underlying storage for improved performance.

    Declaration
    public BaseCollection()

    BaseCollection(IEnumerable<T>)

    Creates a new instance and uses the specified collection for initial population.

    Declaration
    public BaseCollection(IEnumerable<T> collection)
    Parameters
    Type Name Description
    IEnumerable<T> collection

    The initial collection of objects to populate this collection.

    Properties

    Count

    Gets the number of elements in this collection.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32

    IsReadOnly

    Gets the flag that indicates if this collection is read-only.

    Declaration
    public virtual bool IsReadOnly { get; }
    Property Value
    Type Description
    Boolean

    Item[Int32]

    Gets or sets the collection element by index.

    Declaration
    public virtual T this[int index] { get; set; }
    Parameters
    Type Name Description
    Int32 index

    The zero-based index within this collection.

    Property Value
    Type Description
    T

    The element at the specified index in this collection.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown if the specified index is out of range.

    Methods

    Add(T)

    Adds a new element to this collection.

    Declaration
    public virtual void Add(T item)
    Parameters
    Type Name Description
    T item

    The element to add; can be null.

    AddRange(IEnumerable<T>)

    Adds elements of an IEnumerable<T> to the end of this collection.

    Declaration
    public void AddRange(IEnumerable<T> collection)
    Parameters
    Type Name Description
    IEnumerable<T> collection

    The IEnumerable<T> collection whose elements should be added.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if the specified collection is a null reference.

    AsReadOnly()

    Returns a read-only wrapper for this collection.

    Declaration
    public ReadOnlyCollection<T> AsReadOnly()
    Returns
    Type Description
    ReadOnlyCollection<T>

    A ReadOnlyCollection<T> object that is a read-only wrapper for this collection.

    BinarySearch(T)

    Searches the entire sorted collection for an element using the default comparer and returns the zero-based index of the element.

    Declaration
    public int BinarySearch(T item)
    Parameters
    Type Name Description
    T item

    The element for which to search.

    Returns
    Type Description
    Int32

    The zero based index of an element.

    BinarySearch(T, IComparer<T>)

    Searches the entire sorted collection for an element using the specified comparer and returns the zero-based index of the element.

    Declaration
    public int BinarySearch(T item, IComparer<T> comparer)
    Parameters
    Type Name Description
    T item

    The element for which to search.

    IComparer<T> comparer

    The IComparer<T> implementation to use when comparing elements.

    Returns
    Type Description
    Int32

    The zero based index of an element.

    Clear()

    Clears this collection.

    Declaration
    public virtual void Clear()

    Contains(T)

    Checks if the specified item is in this collection.

    Declaration
    public virtual bool Contains(T item)
    Parameters
    Type Name Description
    T item

    The item to find.

    Returns
    Type Description
    Boolean

    True if item is found; otherwise, false.

    CopyTo(T[], Int32)

    Copies elements from this collection to the specified array.

    Declaration
    public void CopyTo(T[] array, int arrayIndex)
    Parameters
    Type Name Description
    T[] array

    The array to which to copy elements.

    Int32 arrayIndex

    The array index at which to start.

    Find(Func<T, Object, Boolean>, Object)

    Searches for an item within this collection using the specified element matching function.

    Declaration
    public T Find(Func<T, object, bool> match, object value)
    Parameters
    Type Name Description
    Func<T, Object, Boolean> match

    Function that evaluates the search condition.

    Object value

    A value to search for.

    Returns
    Type Description
    T

    The item of type T if found; otherwise, default T value.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if the specified predicate is a null reference.

    GetEnumerator()

    Gets the IEnumerator<T> interface that can be used to iterate through this collection.

    Declaration
    public IEnumerator<T> GetEnumerator()
    Returns
    Type Description
    IEnumerator<T>

    The IEnumerator<T> interface.

    IndexOf(T)

    Searches for the specified object and returns the zero-based index of the first occurrence.

    Declaration
    public virtual int IndexOf(T item)
    Parameters
    Type Name Description
    T item

    The object to locate. The value can be a null reference.

    Returns
    Type Description
    Int32

    The zero-based index of the first occurrence of item, if found; otherwise, –1.

    IndexOf(T, Int32)

    Searches for the specified object and returns the zero-based index of the first occurrence.

    Declaration
    public virtual int IndexOf(T item, int index)
    Parameters
    Type Name Description
    T item

    The object to locate. The value can be a null reference.

    Int32 index

    The starting index within this collection.

    Returns
    Type Description
    Int32

    The zero-based index of the first occurrence of item, if found; otherwise, –1.

    Insert(Int32, T)

    Inserts an element into the List at the specified index.

    Declaration
    public virtual void Insert(int index, T item)
    Parameters
    Type Name Description
    Int32 index

    The zero-based index at which item should be inserted.

    T item

    The object to insert. The value can be a null reference.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown if the specified index is out of range.

    Remove(T)

    Removes an element from this collection.

    Declaration
    public virtual bool Remove(T item)
    Parameters
    Type Name Description
    T item

    The element to remove.

    Returns
    Type Description
    Boolean

    True if element was successfully removed; otherwise, false.

    RemoveAt(Int32)

    Removes the element at the specified index.

    Declaration
    public virtual void RemoveAt(int index)
    Parameters
    Type Name Description
    Int32 index

    The zero-based index of the element to remove.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown if the specified index is out of range.

    Sort()

    Sorts the entire collection using the Default comparer.

    Declaration
    public void Sort()

    Sort(IComparer<T>)

    Sorts the entire collection using the specified Comparer<T> comparer.

    Declaration
    public void Sort(IComparer<T> comparer)
    Parameters
    Type Name Description
    IComparer<T> comparer

    The IComparer<T> implementation to use when comparing elements.

    Sort(Comparison<T>)

    Sorts the entire collection using the specified Comparison<T> delegate.

    Declaration
    public void Sort(Comparison<T> comparison)
    Parameters
    Type Name Description
    Comparison<T> comparison

    The Comparison<T> delegate.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if the specified comparison is a null reference.

    Sort(Int32, Int32, IComparer<T>)

    Sorts the range of this collection using the specified Comparer<T> comparer.

    Declaration
    public void Sort(int index, int count, IComparer<T> comparer)
    Parameters
    Type Name Description
    Int32 index

    The zero-based starting index of the range to sort.

    Int32 count

    The length of the range to sort.

    IComparer<T> comparer

    The Comparer<T> to use.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown if the specified index or count is out of range.

    ToArray()

    Copies elements of this collection to a new array.

    Declaration
    public T[] ToArray()
    Returns
    Type Description
    T[]

    An array that contains all elements in this collection.

    Explicit Interface Implementations

    IEnumerable.GetEnumerator()

    Gets the IEnumerator interface that can be used to iterate through this collection.

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    IEnumerator

    The IEnumerator interface.

    Implements

    System.Collections.Generic.IList<T>
    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    Back to top Nevatech Sentinet 6.5 Online Documentation