System.ArraySegment<T> Structure

Delimits a section of a one-dimensional array.

See Also: ArraySegment<T> Members

Syntax

public struct ArraySegment<T> : ICollection<T>, IEnumerable<T>, IList<T>, IReadOnlyCollection<T>, IReadOnlyList<T>

Type Parameters

T
Documentation for this section has not yet been entered.

Remarks

ArraySegment`1 is a wrapper around an array that delimits a range of elements in that array. Multiple ArraySegment`1 instances can refer to the same original array and can overlap. The original array must be one-dimensional and must have zero-based indexing.

The ArraySegment`1.Array property returns the entire original array, not a copy of the array; therefore, changes made to the array returned by the ArraySegment`1.Array property are made to the original array.

The ArraySegment`1.Equals(ArraySegment<`0>) method and the equality and inequality operators test for reference equality when they compare two ArraySegment`1 objects. For two ArraySegment`1 objects to be considered equal, they must meet all of the following conditions:

If you want to retrieve an element by its index in the ArraySegment`1 object, you must cast it to an IList`1 object and retrieve it or modify it by using the IList`1.Item(int) property. The following example retrieves the element in an ArraySegment`1 object that delimits a section of a string array.

code reference: System.ArraySegment.Class#1

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0