ArraySegment(Of T).IList(Of T).Item Property (Int32)

.NET Framework (current version)
 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the element at the specified index.

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

Private Property Item (
	index As Integer
) As T Implements IList(Of T).Item

Parameters

index
Type: System.Int32

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

Property Value

Type: T

The element at the specified index.

Exception Condition
ArgumentOutOfRangeException

index is not a valid index in the ArraySegment(Of T).

NotSupportedException

The property is set and the array segment is read-only.

This member is an explicit interface member implementation. It can be used only when the ArraySegment(Of T) instance is cast to an IList(Of T) interface, as the following example shows.

Imports System.Collections.Generic

Module Example
   Public Sub Main()
      Dim names() As String = { "Adam", "Bruce", "Charles", "Daniel", 
                                "Ebenezer", "Francis", "Gilbert", 
                                "Henry", "Irving", "John", "Karl",
                                "Lucian", "Michael" }
      Dim partNames As New ArraySegment(Of String)(names, 2, 5)

      ' Cast the ArraySegment object to an IList<String> and enumerate it.
      Dim list = CType(partNames, IList(Of String))
      For ctr As Integer = 0 To list.Count - 1
         Console.WriteLine(list(ctr))
      Next     
   End Sub
End Module
' The example displays the following output:
'    Charles
'    Daniel
'    Ebenezer
'    Francis
'    Gilbert

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
Show: