VCCodeElements.Item(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回父对象的指定代码元素。
public:
EnvDTE::CodeElement ^ Item(System::Object ^ index);
public:
EnvDTE::CodeElement ^ Item(Platform::Object ^ index);
EnvDTE::CodeElement Item(winrt::Windows::Foundation::IInspectable const & index);
[System.Runtime.InteropServices.DispId(0)]
public EnvDTE.CodeElement Item (object index);
[<System.Runtime.InteropServices.DispId(0)>]
abstract member Item : obj -> EnvDTE.CodeElement
Public Function Item (index As Object) As CodeElement
参数
- index
- Object
一个对象,表示集合中项的位置。
返回
CodeElement 对象。
实现
- 属性
示例
' Macro code.
' Displays the name of all the top level elements.
Sub FindItem()
Dim vcCM As VCCodeModel
Dim vcCodeElements As VCCodeElements
vcCM = DTE.Solution.Item(1).CodeModel
vcCodeElements = vcCM.CodeElements
Dim i As Integer
For i = 1 To vcCodeElements.Count
MsgBox(vcCodeElements.Item(i))
Next
End Sub
注解
如果未找到指定的代码元素,此方法将返回 null 。
有关如何编译和运行此示例的信息,请参阅 如何:编译 Visual C++ 代码模型扩展性的示例代码 。