IDebugClassField::GetDefaultIndexer
如需 Visual Studio 2017 的最新文件請參閱 Visual Studio 2017 文件。
取得預設索引子的名稱。
語法
HRESULT GetDefaultIndexer(
BSTR* pbstrIndexer
);
int GetDefaultIndexer(
out string pbstrIndexer
);
參數
pbstrIndexer
[out]傳回字串,包含預設索引子的名稱。
傳回值
如果成功,會傳回 S_OK,或如果沒有預設索引子會傳回 S_FALSE。 反之則傳回錯誤碼。
備註
類別的預設索引子是標示為屬性Default
陣列存取的屬性。 這與Visual Basic。 以下是範例中宣告的預設索引子的Visual Basic和使用方式。
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