次の方法で共有


References.Item メソッド

更新 : 2007 年 11 月

インデックス付き Reference オブジェクトを返します。

名前空間 :  VSLangProj
アセンブリ :  VSLangProj (VSLangProj.dll 内)

構文

'宣言
Function Item ( _
    index As Object _
) As Reference
'使用
Dim instance As References
Dim index As Object
Dim returnValue As Reference

returnValue = instance(index)
Reference Item(
    Object index
)
Reference^ Item(
    [InAttribute] Object^ index
)
function Item(
    index : Object
) : Reference

パラメータ

  • index
    型 : System.Object

    必ず指定します。Reference オブジェクトの Identity 文字列、または References コレクションに使用する 1 から始まるインデックスを指定します。

戻り値

型 : VSLangProj.Reference

Reference オブジェクトを返します。

解説

このメソッドは、References コレクションから特定のオブジェクトを取得する場合に使用します。コレクションの項目は追加されたり削除されたりすることがあるため、コレクションのインデックス番号が常に同じ項目を指すとは限りません。コレクションのインデックス番号は、コレクション全体の反復処理を行い、反復処理中に項目数の増減がない場合に使用すると便利です。

' Macro Editor
Imports VSLangProj
Public Sub FindExample()
   ' First project is a Visual Basic or C# project.
   Dim theVSProject As VSProject = _
      CType(DTE.Solution.Projects.Item(1).Object, VSProject)
        
   Dim refs As References = theVSProject.References
   Dim firstIdentity As String = refs.Item(1).Identity
   Dim firstRef As Reference = refs.Find(firstIdentity)
   ' Are they the same object?
   Dim isSame As Boolean = (firstRef.Identity = refs.Item(1).Identity)
   MsgBox("Are they the same? " & isSame.ToString())
End Sub    

アクセス許可

  • 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

References インターフェイス

References メンバ

VSLangProj 名前空間