Parameter.Clone Metoda

Definice

Vrátí duplikát aktuální Parameter instance.

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

Návraty

Jedná Parameter se o přesný duplikát aktuálního.

Příklady

Následující příklad kódu ukazuje, jak volat Parameter(Parameter) konstruktor z třídy, která rozšiřuje Parameter třídy implementovat správné chování klonování objektů pro třídu. Tento příklad kódu je součástí většího příkladu uvedeného pro třídu 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

Poznámky

Metoda Clone volá Parameter(Parameter) konstruktor kopírování k inicializaci nové instance Parameter třídy s hodnotami aktuální instance.

Pokud rozšíříte Parameter třídu, můžete přepsat metodu Clone tak, aby zahrnoval jakýkoli stav, který by se měl zkopírovat do nové instance odvozené třídy.

Platí pro

Viz také