CodeFunction2.RemoveParameter(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从参数列表中删除参数。
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)
参数
- Element
- Object
必需。 集合中的一个 CodeElement 对象或其中一个的名称。
实现
- 属性
示例
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);
}
}
注解
Element 可以是 CodeElement 集合中的对象,也可以是集合中唯一的元素的名称。
单个元素没有 RemoveParameter 方法,因为它们可以存在于多个集合中。 若要删除特定元素,必须调用 Remove 其容器对象的方法。
备注
在进行了某些类型的编辑之后,代码模型元素(例如类、结构、函数、特性、委托等)的值可能变为非确定性的,这意味着不能确定它们的值始终保持不变。