Condividi tramite


Proprietà CodeNamespace.Members

Ottiene una raccolta di elementi contenuti in l CodeNamespace elemento.

Spazio dei nomi:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Sintassi

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

Valore proprietà

Tipo: EnvDTE.CodeElements
In CodeElements raccolta.

Note

Quando il tipo di codice viene vsCMElementDelegate, Members il metodo ha esito negativo perché i delegati non dispongono di membri nel codice sorgente.Vengono contribuiti dal compilatore e da .NET Framework.

[!NOTA]

I valori degli elementi del modello di codice come classi, strutture, le funzioni, gli attributi, delegati, e così via possono non essere deterministici dopo l'inserimento di determinati tipi di modifiche, pertanto i relativi valori non possono essere basati su per rimanere sempre gli stessi.Per ulteriori informazioni, vedere i valori degli elementi del modello di codice della sezione può cambiare in Individuazione di codice mediante il modello di codice (Visual Basic).

Esempi

Sub MembersExample(ByVal dte As DTE2)

    ' Before running this example, open a code document from a project
    ' and place the insertion point inside a namespace definition.
    Try
        ' Retrieve the CodeNamespace at the insertion point.
        Dim sel As TextSelection = _
            CType(dte.ActiveDocument.Selection, TextSelection)
        Dim spc As CodeNamespace = _
            CType(sel.ActivePoint.CodeElement( _
            vsCMElement.vsCMElementNamespace), CodeNamespace)

        ' Display the namespace members.
        Dim members As String
        Dim elem As CodeElement
        For Each elem In spc.Members
            members &= elem.Name & vbCrLf
        Next

        MsgBox(spc.Name & " has the following members:" & _
            vbCrLf & vbCrLf & members)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
public void MembersExample(DTE2 dte)
{
    // Before running this example, open a code document from a project
    // and place the insertion point inside a namespace definition.
    try
    {
        // Retrieve the CodeNamespace at the insertion point.
        TextSelection sel = _
            (TextSelection)dte.ActiveDocument.Selection;
        CodeNamespace spc = _
            (CodeNamespace)sel.ActivePoint.get_CodeElement( _
            vsCMElement.vsCMElementNamespace);

        // Display the namespace members.
        string members = "";
        foreach (CodeElement elem in spc.Members)
        {
            members += elem.Name + Environment.NewLine;
        }

        MessageBox.Show(spc.Name + " has the following members:" + _
            Environment.NewLine + Environment.NewLine + members);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

CodeNamespace Interfaccia

Spazio dei nomi EnvDTE

Altre risorse

Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione

Individuazione di codice mediante il modello di codice (Visual Basic)

Individuazione di codice mediante il modello di codice (Visual C#)