Sdílet prostřednictvím


References.Item(Object) Method

Definition

Returns an indexed Reference object.

public:
 VSLangProj::Reference ^ Item(System::Object ^ index);
public:
 VSLangProj::Reference ^ Item(Platform::Object ^ index);
VSLangProj::Reference Item(winrt::Windows::Foundation::IInspectable const & index);
[System.Runtime.InteropServices.DispId(0)]
public VSLangProj.Reference Item (object index);
[<System.Runtime.InteropServices.DispId(0)>]
abstract member Item : obj -> VSLangProj.Reference
Public Function Item (index As Object) As Reference

Parameters

index
Object

Required. Either the Identity string of the Reference object or a one-based index into the References collection.

Returns

Returns a Reference object.

Attributes

Examples

' 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      

Remarks

This method is used to retrieve a specific object from the References collection. There is no guarantee that a given index number for a collection will always point to the same item, because items may be added or deleted from the collection. Using index numbers for the collection is useful when iterating through the whole collection and no items are added or deleted during the iteration.

Applies to