IDebugClassField::GetDefaultIndexer
Pobiera nazwę domyślnego indeksatora.
Składnia
Parametry
pbstrIndexer
[out] Zwraca ciąg zawierający nazwę indeksatora domyślnego.
Wartość zwracana
Jeśli operacja powiedzie się, zwraca S_OK lub zwraca S_FALSE, jeśli nie ma indeksatora domyślnego. W przeciwnym razie zwraca kod błędu.
Uwagi
Domyślny indeksator klasy to właściwość oznaczona jako Default
właściwość dla dostępu do tablicy. Jest to specyficzne dla języka Visual Basic. Oto przykład domyślnego indeksatora zadeklarowanego w Visual Basic i sposobu jego użycia.
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