References.Item 方法
傳回已建立索引的 Reference 物件。
命名空間: VSLangProj
組件: VSLangProj (在 vslangproj.dll 中)
語法
'宣告
'用途
參數
- index
必要項。Reference 物件的 Identity 字串,或 References 集合的索引 (從 1 開始)。
傳回值
傳回 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