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)构造函数,以实现类的正确对象克隆行为。 此代码示例是为类提供的大型示例的 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 该方法以包含应复制到派生类的新实例的任何状态。

适用于

另请参阅