CodeEnum.Members Property

Gets a collection of items contained by this enumeration.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
ReadOnly Property Members As CodeElements
CodeElements Members { get; }
property CodeElements^ Members {
    CodeElements^ get ();
}
abstract Members : CodeElements
function get Members () : CodeElements

Property Value

Type: EnvDTE.CodeElements
A CodeElements collection.

Remarks

When the code type kind is vsCMElementDelegate, the Members property fails because delegates have no members in the source code. They are contributed by the compiler and the .NET Framework.

Note

The values of code model elements, such as classes, structures, functions, attributes, delegates, cannot be relied upon to remain the same at all times. For more information, see the section Code Model Element Values Can Change in Discovering Code by Using the Code Model (Visual Basic).

Examples

The following example shows how to get the members of an enumeration.

[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 Security

See Also

Reference

CodeEnum Interface

EnvDTE Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples

Discovering Code by Using the Code Model (Visual Basic)

Discovering Code by Using the Code Model (Visual C#)