CodeEnum.Members 屬性

取得這個列舉包含的項目集合。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

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

屬性值

型別:EnvDTE.CodeElements
CodeElements 集合。

備註

當程式碼型別類型為 vsCMElementDelegate 時,Members 屬性會失敗,因為委派在原始程式碼中沒有成員。它們是由編譯器 (Compiler) 和 .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 命名空間

其他資源

HOW TO:編譯和執行 Automation 物件模型程式碼範例

使用程式碼模型探索程式碼 (Visual Basic)

使用程式碼模型探索程式碼 (Visual C#)