Freezable.IsFrozen 屬性

定義

取得值,該值表示物件目前是否可修改。Gets a value that indicates whether the object is currently modifiable.

public:
 property bool IsFrozen { bool get(); };
public bool IsFrozen { get; }
member this.IsFrozen : bool
Public ReadOnly Property IsFrozen As Boolean

屬性值

如果物件已凍結,而且無法修改則為 true,如果可以修改物件則為 falsetrue if the object is frozen and cannot be modified; false if the object can be modified.

備註

嘗試在其 IsFrozen 屬性 true 時修改物件,會擲回 InvalidOperationExceptionAttempting to modify an object when its IsFrozen property is true throws an InvalidOperationException.

從物件模型的觀點來看,這個屬性是唯讀的。This property is read-only from the object model perspective. 關於 Freezable 行為的部分檔可能會在討論 Freezable的其他方法的行為時提及「設定 IsFrozen true」或類似的語言,但此行為是在類別實例內部發生,當實例會操作存在於抽象類別中的私用變數。Some of the documentation about Freezable behaviors may mention "sets IsFrozen to true" or similar language when discussing the behavior of other methods of Freezable, but this behavior is happening internally in the class instances, when methods of the instance manipulate the private variables that exist within the abstract class. 若要設定這個屬性的值,您應該呼叫 FreezeTo set the value of this property, you should call Freeze. 這實際上是一次性的作業,可將 IsFrozen 屬性從初始預設 false 狀態變更為 true 狀態。This effectively is a one-time operation to change the IsFrozen property from the initial default false state to the true state. 沒有任何方法可將值設定回 falseThere is no available means to set the value back to false. 相反地,您可以變更從原始來源進行的任何深層複製(請參閱 Clone 方法)。Instead, you could change any deep copy made from the original (see the Clone method). 這是根據設計,而且是在套用至 Freezable 模式有用的案例時,任何衍生類別的行為方式。This is by design and is how any derived class should behave when applied to the cases where the Freezable pattern is useful.

適用於