Parameter.Clone Metod

Definition

Returnerar en dubblett av den aktuella Parameter instansen.

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

Returer

En Parameter som är en exakt dubblett av den aktuella.

Exempel

Följande kodexempel visar hur du anropar Parameter(Parameter) konstruktorn från en klass som utökar Parameter klassen för att implementera rätt beteende för objektkloning för klassen. Det här kodexemplet är en del av ett större exempel för Parameter klassen.

// 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

Kommentarer

Metoden Clone anropar Parameter(Parameter) kopieringskonstruktorn för att initiera en ny instans av Parameter klassen med värdena för den aktuella instansen.

Om du utökar Parameter klassen kan du åsidosätta Clone metoden för att inkludera alla tillstånd som ska kopieras till en ny instans av din härledda klass.

Gäller för

Se även