Parameter.Clone Metoda

Definicja

Zwraca duplikat bieżącego Parameter wystąpienia.

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

Zwraca

Parameter

Element Parameter , który jest dokładnym duplikatem bieżącego.

Przykłady

W poniższym przykładzie kodu pokazano, jak wywołać Parameter(Parameter) konstruktor z klasy, która rozszerza Parameter klasę w celu zaimplementowania poprawnego zachowania klonowania obiektów dla klasy. Ten przykład kodu jest częścią większego przykładu udostępnionego Parameter dla klasy .

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

Uwagi

Metoda Clone wywołuje konstruktor kopiujący Parameter(Parameter) , aby zainicjować nowe wystąpienie Parameter klasy z wartościami bieżącego wystąpienia.

Jeśli rozszerzysz klasę Parameter , możesz przesłonić metodę Clone tak, aby zawierała dowolny stan, który powinien zostać skopiowany do nowego wystąpienia klasy pochodnej.

Dotyczy

Zobacz też