CodeEnum.Members 属性

获取该枚举包含的项的集合。

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

语法

声明
ReadOnly Property Members As CodeElements
    Get
CodeElements Members { get; }
property CodeElements^ Members {
    CodeElements^ get ();
}
abstract Members : CodeElements
function get Members () : CodeElements

属性值

类型:EnvDTE.CodeElements
一个 CodeElements 集合。

备注

当代码类型种类为 vsCMElementDelegate 时,Members 属性失败,原因是委托在源代码中没有成员。 它们是由编译器和 .NET Framework 提供的。

提示

代码模型元素(如类、结构、功能、属性、委托)的值并不一定总是相同的。 有关更多信息,请参见 使用代码模型查找代码 (Visual Basic) 中的“代码模型元素的值可能会更改”一节。

示例

以下示例显示了如何获取枚举成员。

[Visual Basic]

Sub GetMembersExample(ByVal dte As DTE2)
    ' Before running this example, open a code document from a project
    ' and place the insertion point inside an enumeration.
    Try
        ' Retrieve the CodeEnum at the insertion point.
        Dim sel As TextSelection = _
            CType(dte.ActiveDocument.Selection, TextSelection)
        Dim enm As CodeEnum = _
            CType(sel.ActivePoint.CodeElement( _
            vsCMElement.vsCMElementEnum), CodeEnum)

        ' Get the members of the enumeration.
        Dim elems As CodeElements
        elems = enm.Members
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub

[C#]

public void GetMembersExample(DTE2 dte)
{
    // Before running this example, open a code document from a project
    // and place the insertion point inside an enumeration.
    try
    {
        // Retrieve the CodeEnum at the insertion point.
        TextSelection sel = 
            (TextSelection)dte.ActiveDocument.Selection;
        CodeEnum enm = 
            (CodeEnum)sel.ActivePoint.get_CodeElement(
            vsCMElement.vsCMElementEnum);

        // Get the members of the enumeration.
        CodeElements elems = enm.Members;
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 安全性

请参见

参考

CodeEnum 接口

EnvDTE 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例

使用代码模型查找代码 (Visual Basic)

使用代码模型查找代码 (Visual C#)