共用方式為


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

備註

方法 CloneParameter(Parameter) 呼叫複製建構函式,以使用目前實例 Parameter 的值初始化 類別的新實例。

如果您擴充 Parameter 類別,您可以覆寫 Clone 方法,以包含應該複製到衍生類別之新實例的任何狀態。

適用於

另請參閱