Non-unique elements for custom datatypes
<p>I am trying to get list of unique elements for a custom datatype. I seriously couldn't figure out why this doesn't work. The control never reaches the Equals implementation in the below code. Could someone please help with this?</p>

<pre><code>public class customobj : IEqualityComparer&lt;customobj&gt;
{
    public string str1;
    public string str2;

    public customobj(string s1, string s2)
    {
        this.str1 = s1; this.str2 = s2;
    }

    public bool Equals(customobj obj1, customobj obj2)
    {
        if ((obj1 == null) || (obj2 == null))
        {
            return false;
        }
        return ((obj1.str1.Equals(obj2.str1)) &amp;&amp; (obj2.str2.Equals(obj2.str2)));

    }

    public int GetHashCode(customobj w)
    {
        if (w != null)
        {
            return ((w.str1.GetHashCode()) ^ (w.str2.GetHashCode()));
        }
        return 0;
    }
}
</code></pre>

<p>And below is the part where i am trying to retrieve distinct elements of list.</p>

<pre><code>List&lt;customobj&gt; templist = new List&lt;customobj&gt; { };

templist.Add(new customobj("10", "50"));
templist.Add(new customobj("10", "50"));
List&lt;customobj&gt; dist = templist.Distinct().ToList();
</code></pre>
