ArraySegment<T> Structure

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Delimits a section of a one-dimensional array.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Structure ArraySegment(Of T)
public struct ArraySegment<T>

Type Parameters

  • T
    The type of the elements in the array segment.

The ArraySegment<T> type exposes the following members.

Constructors

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 ArraySegment<T>(array<T[]) Initializes a new instance of the ArraySegment<T> structure that delimits all the elements in the specified array.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 ArraySegment<T>(array<T[], Int32, Int32) Initializes a new instance of the ArraySegment<T> structure that delimits the specified range of the elements in the specified array.

Top

Properties

  Name Description
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 Array Gets the original array containing the range of elements that the array segment delimits.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 Count Gets the number of elements in the range delimited by the array segment.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 Offset Gets the position of the first element in the range delimited by the array segment, relative to the start of the original array.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Equals(ArraySegment<T>) Determines whether the specified ArraySegment<T> structure is equal to the current instance.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Equals(Object) Determines whether the specified object is equal to the current instance. (Overrides ValueType.Equals(Object).)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetHashCode Returns the hash code for the current instance. (Overrides ValueType.GetHashCode().)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 ToString Returns the fully qualified type name of this instance. (Inherited from ValueType.)

Top

Operators

  Name Description
Public operatorStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 Equality Indicates whether two ArraySegment<T> structures are equal.
Public operatorStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 Inequality Indicates whether two ArraySegment<T> structures are unequal.

Top

Remarks

ArraySegment<T> is a wrapper around an array that delimits a range of elements in that array. Multiple ArraySegment<T> instances can refer to the same original array and can overlap.

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

The original array must be one-dimensional and must have zero-based indexing.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference