Struct ReadOnlyListSegment<T>
An efficient read-only wrapper for viewing a list segment as a list.
public struct ReadOnlyListSegment<T> : IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
The type of objects in the wrapped list.
- Implements
-
IEnumerable<T>
- Inherited Members
Constructors
ReadOnlyListSegment(IReadOnlyList<T>, int, int)
Create a new read-only list segment.
public ReadOnlyListSegment(IReadOnlyList<T> innerList, int offset, int count)
Parameters
innerList
IReadOnlyList<T>Wrapped list.
offset
intIndex, with respect to the wrapped list, of the first element in the list segment.
count
intNumber of items in the list segment.
Exceptions
- InvalidOperationException
Thrown if
innerList
isnull
or ifinnerList
has less thanoffset
+count
elements.
Properties
Count
Number of items in the list segment.
public readonly int Count { get; }
Property Value
this[int]
Gets the element at the specified index.
public T this[int index] { get; }
Parameters
index
intThe zero-based index of the element to get.
Property Value
- T
The element at the specified index.
Methods
GetEnumerator()
Returns an enumerator that iterates through the list segment.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An enumerator that can be used to iterate through the list segment.