CodeClass.Bases Eigenschaft

Definition

Ruft eine Auflistung von Klassen ab, von denen dieses Element abgeleitet ist.

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

Eigenschaftswert

CodeElements

Eine CodeElements-Auflistung.

Attribute

Beispiele

Sub BasesExample(ByVal dte As DTE2)  

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

        ' Enumerate the CodeClass's bases.  
        Dim bases As String = ""  
        Dim elem As CodeElement  
        For Each elem In cls.Bases  
            bases &= elem.FullName & vbCrLf  
        Next  

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

End Sub  
public void BasesExample(DTE2 dte)  
{  
    // Before running this example, open a code document from a project  
    // and place the insertion point inside a class definition.  
    try  
    {  
        // Retrieve the CodeClass at the insertion point.  
        TextSelection sel =   
            (TextSelection)dte.ActiveDocument.Selection;  
        CodeClass cls =   
            (CodeClass)sel.ActivePoint.get_CodeElement(  
            vsCMElement.vsCMElementClass);  

        // Enumerate the CodeClass's bases.  
        string bases = "";  
        foreach (CodeElement elem in cls.Bases)  
        {  
           bases += elem.FullName + Environment.NewLine;  
        }  

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

Hinweise

Basen sind Super Typen von CodeElements . Bei Visual Basic und Visual c# gibt es immer nur ein Element in der Auflistung, außer wenn der Codetyp ein ist CodeInterface .

Hinweis

Die Werte von Codemodellelementen wie z. B. Klassen, Strukturen, Funktionen, Attributen Delegaten usw. sind nach bestimmten Änderungen unter Umständen nicht deterministisch, d. h. deren Werte bleiben nicht zuverlässig immer gleich. Weitere Informationen finden Sie im Abschnitt Code Modell Element-Werte können sich in ermitteln von Code mithilfe des Code Modells (Visual Basic)ändern.

Gilt für