Imports System
Imports System.Reflection
Module Example
Sub Main()
Dim test As String = "abcdefghijklmnopqrstuvwxyz"
' To retrieve the value of the indexed Chars property using
' reflection, create an instance of PropertyInfo for Chars.
'
Dim pinfo As PropertyInfo = GetType(String).GetProperty("Chars")
' To retrieve an instance property, the GetValue method
' requires the object whose property is being accessed, and
' an array of objects representing the index values.
' Get the seventh character in the test string.
' Note the index is zero-based.
Dim indexArgs() As Object = {6}
Dim value As Object = pinfo.GetValue(test, indexArgs)
Console.WriteLine(value)
' Show the complete string.
For x As Integer = 0 To test.Length - 1
Console.Write(pinfo.GetValue(test, New Object() {x}))
Next
Console.WriteLine()
End Sub
End Module