共用方式為


CodeFunction2.RemoveParameter 方法

將參數從引數清單移除。

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

語法

'宣告
Sub RemoveParameter ( _
    Element As Object _
)
void RemoveParameter(
    Object Element
)
void RemoveParameter(
    Object^ Element
)
abstract RemoveParameter : 
        Element:Object -> unit
function RemoveParameter(
    Element : Object
)

參數

  • Element
    類型:Object

    必要項。 CodeElement 物件或集合內其中一個名稱。

備註

Element 可以是 CodeElement 位于集合中或在集合中是唯一的元素的名称的对象。

单个元素没有 RemoveParameter 方法因为它们可以存在于多个集合。 若要删除的特定元素,必须调用 Remove 其容器对象的方法。

注意事項注意事項

像是類別、結構、函式、屬性、委派等程式碼模型項目的值,在執行特定類型的編輯後,可能會不具決定性,這表示它們的值不能指望會一律保持相同。有关详细信息,请参阅代码模型元素的值可以更改中的部分 使用程式碼模型探索程式碼 (Visual Basic)

範例

Sub RemoveParameterExample(ByVal dte As DTE2)

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

        If MsgBox("Remove " & param.Name & " from " & fun.Name & "?", _
            MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
            fun.RemoveParameter(param)
        End If
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

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

        if (MessageBox.Show("Remove " + param.Name + " from " + 
            fun.Name + "?", "", MessageBoxButtons.YesNo) == 
            DialogResult.Yes)
            fun.RemoveParameter(param);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 安全性

請參閱

參考

CodeFunction2 介面

EnvDTE80 命名空間

其他資源

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

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

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