ByRef Object. Memberwise Clone(Boolean) 方法
protected: MarshalByRefObject ^ MemberwiseClone(bool cloneIdentity);
protected MarshalByRefObject MemberwiseClone (bool cloneIdentity);
override this.MemberwiseClone : bool -> MarshalByRefObject
Protected Function MemberwiseClone (cloneIdentity As Boolean) As MarshalByRefObject
false，刪除目前 MarshalByRefObject 物件的識別 (Identity)，則會在跨遠端界限進行封送處理時將新的識別指定給物件。
false to delete the current MarshalByRefObject object's identity, which will cause the object to be assigned a new identity when it is marshaled across a remoting boundary.
false 的值通常是適當的。A value of
false is usually appropriate.
true 表示會將目前 MarshalByRefObject 物件的識別複製到其複製品，而造成將遠端用戶端呼叫傳送至遠端伺服器物件。
true to copy the current MarshalByRefObject object's identity to its clone, which will cause remoting client calls to be routed to the remote server object.
MemberwiseClone(Boolean)方法會建立一個新的物件，然後將 MarshalByRefObject 目前物件的非靜態欄位複製到新的物件，藉以建立淺層複製 MarshalByRefObject 。The MemberwiseClone(Boolean) method creates a shallow copy by creating a new MarshalByRefObject object, and then copying the nonstatic fields of the current MarshalByRefObject object to the new object. 如果欄位是實值型別，則會執列欄位的位副本。If a field is a value type, a bit-by-bit copy of the field is performed. 如果欄位是參考型別，則會複製參考，但是參考的物件不是;因此，原始物件與其複製會參考相同的物件。If a field is a reference type, the reference is copied but the referred object is not; therefore, the original object and its clone refer to the same object.
例如，假設有一個 MarshalByRefObject 名為 X 的物件參考物件 a 和 B。物件 B 接著參考物件 C。X 的淺層複本會建立新的物件 X2，也會參考物件 A 和 B。相反地，X 的深層複本會建立新的物件 X2，以參考新的物件（即 A 和 B 的複本），然後參考新的物件 C2，也就是複製 C。使用實介面的類別 ICloneable 來執行物件的深層或淺層複製。For example, consider a MarshalByRefObject object called X that references objects A and B. Object B, in turn, references object C. A shallow copy of X creates new object X2 that also references objects A and B. In contrast, a deep copy of X creates a new object X2 that references the new objects A2 and B2, which are copies of A and B. B2, in turn, references the new object C2, which is a copy C. Use a class that implements the ICloneable interface to perform a deep or shallow copy of an object.
物件的識別 MarshalByRefObject 會定義為遠端伺服器物件，此物件為遠端用戶端呼叫的目標。The identity of a MarshalByRefObject object is defined as the remote server object that is the target of a remoting client call. 根據預設，物件的成員複製品 MarshalByRefObject 具有與原始物件相同的身分識別，這通常不是將跨遠端界限封送處理至用戶端的伺服器端物件之複製的正確行為。By default, the memberwise clone of a MarshalByRefObject object has the same identity as the original object, which is typically not the correct behavior for clones of server-side objects that are marshaled across a remoting boundary to the client side. 指定
true 導致複製保留原始物件的身分識別 MarshalByRefObject 。Specify
false, which is usually appropriate, to delete the identity of the clone and cause a new identity to be assigned when the clone is marshaled across a remoting boundary, or
true to cause the clone to retain the identity of the original MarshalByRefObject object. MemberwiseClone(Boolean)方法主要是供開發人員用來執行遠端伺服器物件。The MemberwiseClone(Boolean) method is intended to be used by developers implementing remote server objects.