IDebugClassField::GetDefaultIndexer
Získá název výchozího indexeru.
Syntaxe
Parametry
pbstrIndexer
[ven] Vrátí řetězec obsahující název výchozího indexeru.
Vrácená hodnota
Pokud je úspěch úspěšný, vrátí S_OK nebo vrátí S_FALSE, pokud neexistuje výchozí indexer. V opačném případě vrátí kód chyby.
Poznámky
Výchozí indexer třídy je vlastnost, která je označena jako Default
vlastnost pro přístup k poli. Toto je specifické pro Jazyk Visual Basic. Tady je příklad výchozího indexeru deklarovaného v jazyce Visual Basic a způsobu jeho použití.
Imports System.Collections;
Public Class Class1
Private myList as Hashtable
Default Public Property Item(ByVal Index As Integer) As Integer
Get
Return CType(List(Index), Integer)
End Get
Set(ByVal Value As Integer)
List(Index) = Value
End Set
End Property
End Class
Function GetItem(Index as Integer) as Integer
Dim classList as Class1 = new Class1
Dim value as Integer
' Access array through default indexer
value = classList(2)
' Access array through explicit property
value = classList.Item(2)
Return value
End Function