次の方法で共有


IDebugClassField::GetDefaultIndexer

Gets the name of the default indexer.

HRESULT GetDefaultIndexer( 
   BSTR* pbstrIndexer
);
int GetDefaultIndexer(
   out string pbstrIndexer
);

Parameters

  • pbstrIndexer
    [out] Returns a string containing the name of the default indexer.

Return Value

If successful, returns S_OK or returns S_FALSE if there is no default indexer. Otherwise, returns an error code.

Remarks

The default indexer of a class is the property that is marked as the Default property for array accesses. This is specific to Visual Basic. Here is an example of a default indexer declared in Visual Basic and how it is used.

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

See Also

Reference

IDebugClassField