Compartilhar via


IDebugClassField::GetDefaultIndexer

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Gets the name of the default indexer.

Syntax

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