mscorlib(4.0.0.0) API with additions
System.ArraySegment< T > Struct Template Reference

Delimits a section of a one-dimensional array. More...

Inheritance diagram for System.ArraySegment< T >:
[legend]
Collaboration diagram for System.ArraySegment< T >:
[legend]

Public Member Functions

 ArraySegment (T[] array)
 Initializes a new instance of the T:System.ArraySegment`1 structure that delimits all the elements in the specified array. More...
 
 ArraySegment (T[] array, int offset, int count)
 Initializes a new instance of the T:System.ArraySegment`1 structure that delimits the specified range of the elements in the specified array. More...
 
override int GetHashCode ()
 Returns the hash code for the current instance. More...
 
override bool Equals (object obj)
 Determines whether the specified object is equal to the current instance. More...
 
bool Equals (ArraySegment< T > obj)
 Determines whether the specified T:System.ArraySegment`1 structure is equal to the current instance. More...
 
int IList< T >. IndexOf (T item)
 Determines the index of a specific item in the array segment. More...
 
void IList< T >. Insert (int index, T item)
 Inserts an item into the array segment at the specified index. More...
 
void IList< T >. RemoveAt (int index)
 Removes the array segment item at the specified index. More...
 
void ICollection< T >. Add (T item)
 Adds an item to the array segment. More...
 
void ICollection< T >. Clear ()
 Removes all items from the array segment. More...
 
bool ICollection< T >. Contains (T item)
 Determines whether the array segment contains a specific value. More...
 
void ICollection< T >. CopyTo (T[] array, int arrayIndex)
 Copies the elements of the array segment to an array, starting at the specified array index. More...
 
bool ICollection< T >. Remove (T item)
 Removes the first occurrence of a specific object from the array segment. More...
 
IEnumerator< T > IEnumerable< T >. GetEnumerator ()
 Returns an enumerator that iterates through the array segment. More...
 
IEnumerator IEnumerable. GetEnumerator ()
 Returns an enumerator that iterates through an array segment. More...
 
- Public Member Functions inherited from System.Collections.IList< T >
int Add (object value)
 Adds an item to the T:System.Collections.IList. More...
 
bool Contains (object value)
 Determines whether the T:System.Collections.IList contains a specific value. More...
 
void Clear ()
 Removes all items from the T:System.Collections.IList. More...
 
int IndexOf (object value)
 Determines the index of a specific item in the T:System.Collections.IList. More...
 
void Insert (int index, object value)
 Inserts an item to the T:System.Collections.IList at the specified index. More...
 
void Remove (object value)
 Removes the first occurrence of a specific object from the T:System.Collections.IList. More...
 
void RemoveAt (int index)
 Removes the T:System.Collections.IList item at the specified index. More...
 
- Public Member Functions inherited from System.Collections.ICollection< T >
void CopyTo (Array array, int index)
 Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a particular T:System.Array index. More...
 
- Public Member Functions inherited from System.Collections.IEnumerable< T >
IEnumerator GetEnumerator ()
 Returns an enumerator that iterates through a collection. More...
 

Static Public Member Functions

static bool operator== (ArraySegment< T > a, ArraySegment< T > b)
 Indicates whether two T:System.ArraySegment`1 structures are equal. More...
 
static bool operator != (ArraySegment< T > a, ArraySegment< T > b)
 Indicates whether two T:System.ArraySegment`1 structures are unequal. More...
 

Properties

T [] Array [get]
 Gets the original array containing the range of elements that the array segment delimits. More...
 
int Offset [get]
 Gets the position of the first element in the range delimited by the array segment, relative to the start of the original array. More...
 
int Count [get]
 Gets the number of elements in the range delimited by the array segment. More...
 
T IList< T >. this[int index] [get, set]
 Gets or sets the element at the specified index. More...
 
T IReadOnlyList< T >. this[int index] [get]
 Gets the element at the specified index of the array segment. More...
 
bool ICollection< T >. IsReadOnly [get]
 Gets a value that indicates whether the array segment is read-only. More...
 
- Properties inherited from System.Collections.IList< T >
object this[int index] [get, set]
 Gets or sets the element at the specified index. More...
 
bool IsReadOnly [get]
 Gets a value indicating whether the T:System.Collections.IList is read-only. More...
 
bool IsFixedSize [get]
 Gets a value indicating whether the T:System.Collections.IList has a fixed size. More...
 
- Properties inherited from System.Collections.ICollection< T >
int Count [get]
 Gets the number of elements contained in the T:System.Collections.ICollection. More...
 
object SyncRoot [get]
 Gets an object that can be used to synchronize access to the T:System.Collections.ICollection. More...
 
bool IsSynchronized [get]
 Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (thread safe). More...
 
- Properties inherited from System.Collections.Generic.IReadOnlyList< T >
this[int index] [get]
 Gets the element at the specified index in the read-only list. More...
 
- Properties inherited from System.Collections.Generic.IReadOnlyCollection< T >
int Count [get]
 Gets the number of elements in the collection. More...
 

Detailed Description

Delimits a section of a one-dimensional array.

Template Parameters
TThe type of the elements in the array segment.

Definition at line 10 of file ArraySegment.cs.

Constructor & Destructor Documentation

◆ ArraySegment() [1/2]

System.ArraySegment< T >.ArraySegment ( T []  array)

Initializes a new instance of the T:System.ArraySegment`1 structure that delimits all the elements in the specified array.

Parameters
arrayThe array to wrap.
Exceptions
T:System.ArgumentNullExceptionarray is null.

Definition at line 196 of file ArraySegment.cs.

◆ ArraySegment() [2/2]

System.ArraySegment< T >.ArraySegment ( T []  array,
int  offset,
int  count 
)

Initializes a new instance of the T:System.ArraySegment`1 structure that delimits the specified range of the elements in the specified array.

Parameters
arrayThe array containing the range of elements to delimit.
offsetThe zero-based index of the first element in the range.
countThe number of elements in the range.
Exceptions
T:System.ArgumentNullExceptionarray is null.
T:System.ArgumentOutOfRangeExceptionoffset or count is less than 0.
T:System.ArgumentExceptionoffset and count do not specify a valid range in array .

Definition at line 218 of file ArraySegment.cs.

Member Function Documentation

◆ Add()

void ICollection<T>. System.ArraySegment< T >.Add ( T  item)

Adds an item to the array segment.

Parameters
itemThe object to add to the array segment.
Exceptions
T:System.NotSupportedExceptionThe array segment is read-only.

Definition at line 348 of file ArraySegment.cs.

◆ Clear()

void ICollection<T>. System.ArraySegment< T >.Clear ( )

Removes all items from the array segment.

Exceptions
T:System.NotSupportedExceptionThe array segment is read-only.

Definition at line 356 of file ArraySegment.cs.

◆ Contains()

bool ICollection<T>. System.ArraySegment< T >.Contains ( T  item)

Determines whether the array segment contains a specific value.

Parameters
itemThe object to locate in the array segment.
Returns
true if item is found in the array segment; otherwise, false.

Definition at line 366 of file ArraySegment.cs.

◆ CopyTo()

void ICollection<T>. System.ArraySegment< T >.CopyTo ( T []  array,
int  arrayIndex 
)

Copies the elements of the array segment to an array, starting at the specified array index.

Parameters
arrayThe one-dimensional array that is the destination of the elements copied from the array segment. The array must have zero-based indexing.
arrayIndexThe zero-based index in array at which copying begins.
Exceptions
T:System.ArgumentNullExceptionarray is null.
T:System.ArgumentOutOfRangeExceptionarrayIndex is less than 0.
T:System.ArgumentExceptionarray is multidimensional.-or-The number of elements in the source array segment is greater than the available space from arrayIndex to the end of the destination array .-or-Type T cannot be cast automatically to the type of the destination array .

Definition at line 386 of file ArraySegment.cs.

◆ Equals() [1/2]

override bool System.ArraySegment< T >.Equals ( object  obj)

Determines whether the specified object is equal to the current instance.

Parameters
objThe object to be compared with the current instance.
Returns
true if the specified object is a T:System.ArraySegment`1 structure and is equal to the current instance; otherwise, false.

Definition at line 258 of file ArraySegment.cs.

◆ Equals() [2/2]

bool System.ArraySegment< T >.Equals ( ArraySegment< T obj)

Determines whether the specified T:System.ArraySegment`1 structure is equal to the current instance.

Parameters
objThe structure to compare with the current instance.
Returns
true if the specified T:System.ArraySegment`1 structure is equal to the current instance; otherwise, false.

Definition at line 272 of file ArraySegment.cs.

◆ GetEnumerator() [1/2]

IEnumerator<T> IEnumerable<T>. System.ArraySegment< T >.GetEnumerator ( )

Returns an enumerator that iterates through the array segment.

Returns
An enumerator that can be used to iterate through the array segment.

Implements System.Collections.IEnumerable.

Definition at line 409 of file ArraySegment.cs.

◆ GetEnumerator() [2/2]

IEnumerator IEnumerable. System.ArraySegment< T >.GetEnumerator ( )

Returns an enumerator that iterates through an array segment.

Returns
An enumerator that can be used to iterate through the array segment.

Implements System.Collections.IEnumerable.

Definition at line 421 of file ArraySegment.cs.

◆ GetHashCode()

override int System.ArraySegment< T >.GetHashCode ( )

Returns the hash code for the current instance.

Returns
A 32-bit signed integer hash code.

Definition at line 244 of file ArraySegment.cs.

◆ IndexOf()

int IList<T>. System.ArraySegment< T >.IndexOf ( T  item)

Determines the index of a specific item in the array segment.

Parameters
itemThe object to locate in the array segment.
Returns
The index of item if found in the list; otherwise, -1.

Definition at line 307 of file ArraySegment.cs.

◆ Insert()

void IList<T>. System.ArraySegment< T >.Insert ( int  index,
T  item 
)

Inserts an item into the array segment at the specified index.

Parameters
indexThe zero-based index at which item should be inserted.
itemThe object to insert into the array segment.
Exceptions
T:System.ArgumentOutOfRangeExceptionindex is not a valid index in the array segment.
T:System.NotSupportedExceptionThe array segment is read-only.

Definition at line 328 of file ArraySegment.cs.

◆ operator !=()

static bool System.ArraySegment< T >.operator != ( ArraySegment< T a,
ArraySegment< T b 
)
static

Indicates whether two T:System.ArraySegment`1 structures are unequal.

Parameters
aThe structure on the left side of the inequality operator.
bThe structure on the right side of the inequality operator.
Returns
true if a is not equal to b ; otherwise, false.

Definition at line 298 of file ArraySegment.cs.

◆ operator==()

static bool System.ArraySegment< T >.operator== ( ArraySegment< T a,
ArraySegment< T b 
)
static

Indicates whether two T:System.ArraySegment`1 structures are equal.

Parameters
aThe structure on the left side of the equality operator.
bThe structure on the right side of the equality operator.
Returns
true if a is equal to b ; otherwise, false.

Definition at line 287 of file ArraySegment.cs.

◆ Remove()

bool ICollection<T>. System.ArraySegment< T >.Remove ( T  item)

Removes the first occurrence of a specific object from the array segment.

Parameters
itemThe object to remove from the array segment.
Returns
true if item was successfully removed from the array segment; otherwise, false. This method also returns false if item is not found in the array segment.
Exceptions
T:System.NotSupportedExceptionThe array segment is read-only.

Definition at line 401 of file ArraySegment.cs.

◆ RemoveAt()

void IList<T>. System.ArraySegment< T >.RemoveAt ( int  index)

Removes the array segment item at the specified index.

Parameters
indexThe zero-based index of the item to remove.
Exceptions
T:System.ArgumentOutOfRangeExceptionindex is not a valid index in the array segment.
T:System.NotSupportedExceptionThe array segment is read-only.

Definition at line 339 of file ArraySegment.cs.

Property Documentation

◆ Array

Gets the original array containing the range of elements that the array segment delimits.

Returns
The original array that was passed to the constructor, and that contains the range delimited by the T:System.ArraySegment`1.

Definition at line 85 of file ArraySegment.cs.

◆ Count

int System.ArraySegment< T >.Count
get

Gets the number of elements in the range delimited by the array segment.

Returns
The number of elements in the range delimited by the T:System.ArraySegment`1.

Definition at line 109 of file ArraySegment.cs.

◆ IsReadOnly

bool ICollection<T>. System.ArraySegment< T >.IsReadOnly
get

Gets a value that indicates whether the array segment is read-only.

Returns
true if the array segment is read-only; otherwise, false.

Definition at line 183 of file ArraySegment.cs.

◆ Offset

int System.ArraySegment< T >.Offset
get

Gets the position of the first element in the range delimited by the array segment, relative to the start of the original array.

Returns
The position of the first element in the range delimited by the T:System.ArraySegment`1, relative to the start of the original array.

Definition at line 97 of file ArraySegment.cs.

◆ this[int index] [1/2]

T IList<T>. System.ArraySegment< T >.this[int index]
getset

Gets or sets the element at the specified index.

Parameters
indexThe zero-based index of the element to get or set.
Returns
The element at the specified index.
Exceptions
T:System.ArgumentOutOfRangeExceptionindex is not a valid index in the T:System.ArraySegment`1.
T:System.NotSupportedExceptionThe property is set and the array segment is read-only.

Definition at line 125 of file ArraySegment.cs.

◆ this[int index] [2/2]

T IReadOnlyList<T>. System.ArraySegment< T >.this[int index]
get

Gets the element at the specified index of the array segment.

Parameters
indexThe zero-based index of the element to get.
Returns
The element at the specified index.
Exceptions
T:System.ArgumentOutOfRangeExceptionindex is not a valid index in the T:System.ArraySegment`1.
T:System.NotSupportedExceptionThe property is set.

Definition at line 162 of file ArraySegment.cs.


The documentation for this struct was generated from the following file: