CodeClass2.Bases Eigenschaft

Definition

Ruft eine Auflistung von Klassen ab, von denen diese Codeklasse 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.

Implementiert

Attribute

Beispiele

[Visual Basic]

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 CodeClass2 = _  
            CType(sel.ActivePoint.CodeElement( _  
            vsCMElement.vsCMElementClass), CodeClass2)  

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

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

[C#]

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;  
        CodeClass2 cls =   
            (CodeClass)sel.ActivePoint.get_CodeElement2(  
            vsCMElement.vsCMElementClass);  

        // Enumerate the CodeClass's bases.  
        string bases = "";  
        foreach (CodeElement2 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 CodeInterface oder ist CodeInterface2 .

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