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

適用対象

こちらもご覧ください