GemBox.Document
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    ElementCollection<T> Class

    Namespace:
    GemBox.Document
    Assembly:
    GemBox.Document.dll

    Represents a base generic class for Element collections.

    • C#
    • VB.NET
    public class ElementCollection<T> : ElementCollection, IList, ICollection, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable
    Public Class ElementCollection(Of T As Element)
        Inherits ElementCollection
        Implements IList, ICollection, IList(Of T), ICollection(Of T), IEnumerable(Of T), IEnumerable
    Type Parameters
    T

    An Element derived type.

    Inheritance:
    System.Object
    ElementCollection
    ElementCollection<T>
    Derived
    BlockCollection
    HeaderFooterCollection
    InlineCollection
    SectionCollection
    TableCellCollection
    TableRowCollection
    Implements
    System.Collections.IList
    System.Collections.ICollection
    System.Collections.Generic.IList<T>
    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable

    Properties

    Count

    Gets the number of elements contained in the ElementCollection<T>.

    • C#
    • VB.NET
    public int Count { get; }
    Public ReadOnly Property Count As Integer
    Property Value
    System.Int32

    The number of elements contained in the ElementCollection<T>.

    Item[Int32]

    Gets or sets the element at the specified index.

    • C#
    • VB.NET
    public T this[int index] { get; set; }
    Public Property Item(index As Integer) As T
    Parameters
    index
    System.Int32

    The zero-based index of the element to get or set.

    Property Value
    T

    The element at the specified index.

    Methods

    Add(T)

    Adds an object to the end of the ElementCollection<T>.

    • C#
    • VB.NET
    public void Add(T item)
    Public Sub Add(item As T)
    Parameters
    item
    T

    The object to be added to the end of the ElementCollection<T>.

    Cast<TElement>(Int32)

    Gets the element at the specified index and casts it to the specified type.

    • C#
    • VB.NET
    public TElement Cast<TElement>(int index)
        where TElement : T
    Public Function Cast(Of TElement As T)(index As Integer) As TElement
    Parameters
    index
    System.Int32

    The zero-based index of the element to get.

    Returns
    TElement

    The element at the specified index casted to TElement type.

    Type Parameters
    TElement

    The type to cast the element to.

    Remarks

    This method serves as a utility method for casting. Default C# explicit casting, when used in a chain, makes code hard to write and read. This method makes the chain casting code more clear and maintainable.

    Exceptions
    System.ArgumentOutOfRangeException

    index is less than 0 or is equal to or greater than Count.

    System.InvalidCastException

    An element at the specified index cannot be cast to type TElement.

    Clear()

    Removes all elements from the ElementCollection<T>.

    • C#
    • VB.NET
    public void Clear()
    Public Sub Clear

    Contains(T)

    Determines whether an element is in the ElementCollection<T>.

    • C#
    • VB.NET
    public bool Contains(T item)
    Public Function Contains(item As T) As Boolean
    Parameters
    item
    T

    The element to locate in the ElementCollection<T>.

    Returns
    System.Boolean

    true if item is found in the ElementCollection<T>; otherwise, false.

    CopyTo(T[], Int32)

    Copies the entire ElementCollection<T> to a compatible one-dimensional array, starting at the specified index of the target array.

    • C#
    • VB.NET
    public void CopyTo(T[] array, int arrayIndex)
    Public Sub CopyTo(array As T(), arrayIndex As Integer)
    Parameters
    array
    T[]

    The one-dimensional array that is the destination of the elements copied from ElementCollection<T>.

    arrayIndex
    System.Int32

    The zero-based index in array at which copying begins.

    GetEnumerator()

    Returns an enumerator that iterates through the ElementCollection<T>.

    • C#
    • VB.NET
    public IEnumerator<T> GetEnumerator()
    Public Function GetEnumerator As IEnumerator(Of T)
    Returns
    System.Collections.Generic.IEnumerator<T>

    An enumerator for the ElementCollection<T>.

    IndexOf(T)

    Searches for the specified element and returns the zero-based index of the first occurrence within the entire ElementCollection<T>.

    • C#
    • VB.NET
    public int IndexOf(T item)
    Public Function IndexOf(item As T) As Integer
    Parameters
    item
    T

    The element to locate in the ElementCollection<T>.

    Returns
    System.Int32

    The zero-based index of the first occurrence of item within the entire ElementCollection<T>, if found; otherwise, -1.

    Insert(Int32, T)

    Inserts an element into the ElementCollection<T> at the specified index.

    • C#
    • VB.NET
    public void Insert(int index, T item)
    Public Sub Insert(index As Integer, item As T)
    Parameters
    index
    System.Int32

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

    item
    T

    The element to insert.

    Remove(T)

    Removes the first occurrence of a specific element from the ElementCollection<T>.

    • C#
    • VB.NET
    public bool Remove(T item)
    Public Function Remove(item As T) As Boolean
    Parameters
    item
    T

    The element from the ElementCollection<T>.

    Returns
    System.Boolean

    true if item is successfully removed; otherwise, false. This method also returns false if item was not found in the ElementCollection<T>.

    RemoveAt(Int32)

    Removes the element at the specified index of the ElementCollection<T>.

    • C#
    • VB.NET
    public void RemoveAt(int index)
    Public Sub RemoveAt(index As Integer)
    Parameters
    index
    System.Int32

    The zero-based index of the element to remove.

    Inherited Properties

    Content

    Gets the content of the current ElementCollection.

    (Inherited from ElementCollection)

    SupportedElementTypes

    Gets a sequence of ElementTypes that can be contained in this collection.

    (Inherited from ElementCollection)

    Inherited Methods

    CopyTo(Element[], System.Int32)

    Copies the elements of the ElementCollection to an System.Array, starting at a particular System.Array index.

    (Inherited from ElementCollection)

    IndexOf(Element)

    Determines the index of a specific Element in the ElementCollection.

    (Inherited from ElementCollection)

    Implements

    System.Collections.IList
    System.Collections.ICollection
    System.Collections.Generic.IList<T>
    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.