Parameter.Clone 方法

定义

返回当前 Parameter 实例的副本。

protected:
 virtual System::Web::UI::WebControls::Parameter ^ Clone();
protected virtual System.Web.UI.WebControls.Parameter Clone();
abstract member Clone : unit -> System.Web.UI.WebControls.Parameter
override this.Clone : unit -> System.Web.UI.WebControls.Parameter
Protected Overridable Function Clone () As Parameter

返回

Parameter这是当前副本的完全重复项。

示例

下面的代码示例演示如何从扩展 Parameter(Parameter) 类的类调用 Parameter 构造函数,以实现类的正确对象克隆行为。 该代码示例是 Parameter 类中的一个较大示例的一部分。

// The StaticParameter copy constructor is provided to ensure that
// the state contained in the DataValue property is copied to new
// instances of the class.
protected StaticParameter(StaticParameter original) : base(original) {
  DataValue = original.DataValue;
}

// The Clone method is overridden to call the
// StaticParameter copy constructor, so that the data in
// the DataValue property is correctly transferred to the
// new instance of the StaticParameter.
protected override Parameter Clone() {
  return new StaticParameter(this);
}
' The StaticParameter copy constructor is provided to ensure that
' the state contained in the DataValue property is copied to new
' instances of the class.
Protected Sub New(original As StaticParameter)
   MyBase.New(original)
   DataValue = original.DataValue
End Sub

' The Clone method is overridden to call the
' StaticParameter copy constructor, so that the data in
' the DataValue property is correctly transferred to the
' new instance of the StaticParameter.
Protected Overrides Function Clone() As Parameter
   Return New StaticParameter(Me)
End Function

注解

该方法 Clone 调用 Parameter(Parameter) 复制构造函数,以使用当前实例的值初始化类的新实例 Parameter

如果扩展类 Parameter ,可以重写 Clone 该方法以包含应复制到派生类的新实例的任何状态。

适用于

另请参阅