Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Edit: It is not possible to do the comparison that you want because ReferenceEqual is really meant to check wheter it is the same object. From <a href="http://msdn.microsoft.com/en-us/library/system.object.referenceequals%28v=vs.100%29.aspx" rel="nofollow">msdn</a></p> <blockquote> <p>Unlike the Equals method and the equality operator, the ReferenceEquals method cannot be overridden. Because of this, if you want to test two object references for equality and are unsure about the implementation of the Equals method, you can call the ReferenceEquals method. However, note that if objA and objB are value types, they are boxed before they are passed to the ReferenceEquals method.</p> </blockquote> <p>So if you want to have the ReferenceEqual the only way you can do it as I described below.</p> <p>Original Post</p> <p>On the first check you get true because of these statements</p> <pre><code>ck1.Numbers = new int[] { 11, 12, 13 }; ck2.Numbers = ck1.Numbers; </code></pre> <p>The second line makes that ck2 refers to the same object as ck1.</p> <p>On deserialization you do</p> <pre><code>Check ck3 = (Check)oos.Deserialize(fs); Check ck4 = (Check)oos.Deserialize(fs); </code></pre> <p>What you do here is create two new objects and ck3 and ck4 refer to different objects. To get the same results as before serialization you shuold do</p> <pre><code>Check ck3 = (Check)oos.Deserialize(fs); Check ck4 = ck3; </code></pre> <p>Here an new object ck3 is created and ck4 = ck3 ensures that both refer to the same object.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload