Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em><strong>Equals -</em></strong> </p> <p>1- Override the GetHashCode method to allow a type to work correctly in a hash table.</p> <p>2- Do not throw an exception in the implementation of an Equals method. Instead, return false for a null argument.</p> <p>3-</p> <pre><code> x.Equals(x) returns true. x.Equals(y) returns the same value as y.Equals(x). (x.Equals(y) &amp;&amp; y.Equals(z)) returns true if and only if x.Equals(z) returns true. </code></pre> <p>Successive invocations of x.Equals(y) return the same value as long as the object referenced by x and y are not modified.</p> <pre><code> x.Equals(null) returns false. </code></pre> <p>4- For some kinds of objects, it is desirable to have Equals test for value equality instead of referential equality. Such implementations of Equals return true if the two objects have the same value, even if they are not the same instance.</p> <p>For Example - </p> <pre><code> Object obj1 = new Object(); Object obj2 = new Object(); Console.WriteLine(obj1.Equals(obj2)); obj1 = obj2; Console.WriteLine(obj1.Equals(obj2)); </code></pre> <p>Output :-</p> <pre><code> False True </code></pre> <p>while <strong><em>compareTo</em></strong> -</p> <p>Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.</p> <p>It returns - </p> <p>Less than zero - This instance precedes obj in the sort order. Zero - This instance occurs in the same position in the sort order as obj. Greater than zero - This instance follows obj in the sort order.</p> <p>It can throw ArgumentException if object is not the same type as instance.</p> <p>For example you can visit <a href="http://msdn.microsoft.com/en-us/library/system.icomparable.compareto.aspx" rel="nofollow">here</a>.</p> <p>So I suggest better to use Equals in place of compareTo.</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