CodeFunction.Type 屬性

設定或取得表示程式設計型別的物件。

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

語法

'宣告
Property Type As CodeTypeRef
    Get
    Set
CodeTypeRef Type { get; set; }
property CodeTypeRef^ Type {
    CodeTypeRef^ get ();
    void set (CodeTypeRef^ value);
}
abstract Type : CodeTypeRef with get, set
function get Type () : CodeTypeRef
function set Type (value : CodeTypeRef)

屬性值

型別:EnvDTE.CodeTypeRef
CodeTypeRef 物件。

備註

對於具有預設型別概念的程式語言,Type 可能會傳回 Nothing。

注意事項注意事項

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

範例

 Sub TypeExample(ByVal dte As DTE2)

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

        MsgBox(fun.Name & "'s return type is " & fun.Type.AsFullName)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
 public void TypeExample(DTE2 dte)
{
    // Before running this example, open a code document from a project
    // and place the insertion point inside a function.
    try
    {
        // Retrieve the CodeFunction at the insertion point.
        TextSelection sel = 
            (TextSelection)dte.ActiveDocument.Selection;
        CodeFunction fun = 
            (CodeFunction)sel.ActivePoint.get_CodeElement(
            vsCMElement.vsCMElementFunction);

        MessageBox.Show(fun.Name + "'s return type is " + 
            fun.Type.AsFullName);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 安全性

請參閱

參考

CodeFunction 介面

EnvDTE 命名空間

其他資源

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

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

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