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 メソッドをオーバーライドして、派生クラスの新しいインスタンスにコピーする必要がある状態を含めることができます。

適用対象

こちらもご覧ください