CodeClass.IsAbstract 屬性

設定或取得項目是否宣告為抽象。

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

語法

'宣告
Property IsAbstract As Boolean
    Get
    Set
bool IsAbstract { get; set; }
property bool IsAbstract {
    bool get ();
    void set (bool value);
}
abstract IsAbstract : bool with get, set
function get IsAbstract () : boolean
function set IsAbstract (value : boolean)

屬性值

型別:System.Boolean
布林值,如果項目被宣告為抽象,則表示為 true,否則為 false。

備註

IsAbstract 會傳回或設定該類別目前是否顯示為抽象 (不一定會將該類別宣告為抽象,但可能會隱含的宣告),或者需要一個加入方法實作 (由於抽象方法而遺漏) 的子類別。 對於某些程式語言而言,這可能永遠都是 False。

注意事項注意事項

在特定類型的編輯之後,程式碼模型項目 (例如類別、結構、函式、屬性、委派等) 的值可能不具決定性,表示其值不一定維持相同。 如需詳細資訊,請參閱使用程式碼模型探索程式碼 (Visual Basic) 的<程式碼模型項目值可以變更>一節。

範例

 Sub IsAbstractExample(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)

        ' Display whether the class is abstract.
        If cls.IsAbstract Then
            MsgBox(cls.Name & " is an abstract class.")
        Else
            MsgBox(cls.Name & " is not an abstract class.")
        End If
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
public void IsAbstractExample(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);

        // Display whether the class is abstract.
        if (cls.IsAbstract)
            MessageBox.Show(cls.Name + " is an abstract class.");
        else
            MessageBox.Show(cls.Name + " is not an abstract class.");
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 安全性

請參閱

參考

CodeClass 介面

EnvDTE 命名空間

其他資源

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

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

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