Compartir a través de


CodeEnum.Members Property

Definition

Gets a collection of items contained by this enumeration.

public:
 property EnvDTE::CodeElements ^ Members { EnvDTE::CodeElements ^ get(); };
[System.Runtime.InteropServices.DispId(34)]
public EnvDTE.CodeElements Members { [System.Runtime.InteropServices.DispId(34)] [System.Runtime.InteropServices.TypeLibFunc(1024)] get; }
[<System.Runtime.InteropServices.DispId(34)>]
[<get: System.Runtime.InteropServices.DispId(34)>]
[<get: System.Runtime.InteropServices.TypeLibFunc(1024)>]
member this.Members : EnvDTE.CodeElements
Public ReadOnly Property Members As CodeElements

Property Value

A CodeElements collection.

Attributes

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);  
    }  
}  

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).

Applies to