CodeFunction.Type 属性

设置或获取表示编程类型的对象。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
Property Type As CodeTypeRef
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 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例

使用代码模型查找代码 (Visual Basic)

使用代码模型查找代码 (Visual C#)