共用方式為


CodeFunction.FunctionKind 屬性

取得列舉型別,描述函式的使用方式。

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

語法

'宣告
ReadOnly Property FunctionKind As vsCMFunction
vsCMFunction FunctionKind { get; }
property vsCMFunction FunctionKind {
    vsCMFunction get ();
}
abstract FunctionKind : vsCMFunction with get
function get FunctionKind () : vsCMFunction

屬性值

類型:EnvDTE.vsCMFunction
vsCMFunction 值。

備註

FunctionKind 會傳回函式的型別,例如 Property Get、Property Let、Sub 或 Function。

vsCMFunction 值必須同時經過位元 OR 處理。 Visual C++ 結合了這幾個值,以正確描述某個函式。 例如:virtual int MyProc() const = 0;。

MyProc 會得到 (vsCMFunctionFunction | vsCMFunctionVirtual | vsCMFunctionConstant | vsCMFunctionPure | vsCMFunctionTopLevel) 值。

另一個範例為:inline void AnotherOne()。

這會得到 (vsCMFunctionSub | vsCMFunctionInline, vsCMFunctionTopLevel) 值。

注意事項注意事項

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

範例

 Sub FunctionKindExample(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 kind is " & fun.FunctionKind.ToString())
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
 public void FunctionKindExample(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 kind is " + 
            fun.FunctionKind.ToString());
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 安全性

請參閱

參考

CodeFunction 介面

EnvDTE 命名空間

其他資源

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

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

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