References.Item 方法

返回一个已索引的 Reference 对象。

命名空间:  VSLangProj
程序集:  VSLangProj(在 VSLangProj.dll 中)

语法

声明
Function Item ( _
    index As Object _
) As Reference
Reference Item(
    Object index
)
Reference^ Item(
    [InAttribute] Object^ index
)
abstract Item : 
        index:Object -> Reference
function Item(
    index : Object
) : Reference

参数

  • index
    类型: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    

.NET Framework 安全性

请参阅

参考

References 接口

VSLangProj 命名空间