Parameter.Clone メソッド
アセンブリ: System.Web (system.web.dll 内)
構文
解説
Clone メソッドは、Parameter(Parameter) コピー コンストラクタを呼び出して、Parameter クラスの新しいインスタンスを現在のインスタンスの値で初期化します。
Parameter クラスを拡張する場合、Clone メソッドをオーバーライドして、派生クラスの新しいインスタンスにコピーする必要のある状態を含めることができます。
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 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
// 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 StaticParameter(StaticParameter original) { super(original); set_DataValue(original.get_DataValue()); } //StaticParameter // 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 Parameter Clone() { return new StaticParameter(this); } //Clone
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- Parameter.Clone メソッドのページへのリンク