Sdílet prostřednictvím


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

Parameter

Jedná se Parameter 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řídu na implementaci správného chování klonování objektů pro třídu. Tento příklad kódu je součástí většího příkladu zadaného Parameter pro třídu.

// 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 třídu rozšíříte Parameter , můžete metodu Clone přepsat tak, aby zahrnovala libovolný stav, který by se měl zkopírovat do nové instance odvozené třídy.

Platí pro

Viz také