ArrayList.Item Property gets or sets the element at the specified index.
Imports System
Imports System.Collections
Imports Microsoft.VisualBasic
Public Class Example
Public Shared Sub Main
Dim stringList As New ArrayList
stringList.Add("a")
stringList.Add("abc")
stringList.Add("abcdef")
stringList.Add("abcdefg")
Console.WriteLine("Element {0} is ""{1}""", 2, stringList(2))
stringList(2) = "abcd"
Console.WriteLine("Element {0} is ""{1}""", 2, stringList(2))
Console.WriteLine(stringList.Count)
Try
Console.WriteLine("Element {0} is ""{1}""",stringList.Count,stringList(stringList.Count))
Catch aoore As ArgumentOutOfRangeException
Console.WriteLine("stringList({0}) is out of range.",stringList.Count)
End Try
End Sub
End Class
Related examples in the same category