Partager via


CodeFunction2.RemoveParameter(Object) Method

Definition

Removes a parameter from the argument list.

public:
 void RemoveParameter(System::Object ^ Element);
public:
 void RemoveParameter(Platform::Object ^ Element);
void RemoveParameter(winrt::Windows::Foundation::IInspectable const & Element);
[System.Runtime.InteropServices.DispId(49)]
public void RemoveParameter (object Element);
[<System.Runtime.InteropServices.DispId(49)>]
abstract member RemoveParameter : obj -> unit
Public Sub RemoveParameter (Element As Object)

Parameters

Element
Object

Required. A CodeElement object or the name of one in the collection.

Implements

Attributes

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);  
    }  
}  

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.

Applies to