Share via


CodeFunction.RemoveParameter Method

Removes a parameter from the argument list.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

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

Parameters

Remarks

Element can either be a CodeElement object that is in the collection, or the name of an element that is unique within the collection.

Individual elements do not have a RemoveParameter method because they can exist in multiple collections. To remove a specific element, you must call the Remove method of its container object.

Note

The values of code model elements such as classes, structs, functions, attributes, delegates, and so forth can be non-deterministic after making certain kinds of edits, meaning that their values cannot be relied upon to always remain the same. For more information, see the section Code Model Element Values Can Change in Discovering Code by Using the Code Model (Visual Basic).

Examples

 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 Security

See Also

Reference

CodeFunction Interface

EnvDTE Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples

Discovering Code by Using the Code Model (Visual Basic)

Discovering Code by Using the Code Model (Visual C#)