<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Snipplr</title>
    <description>Recent snippets posted on Snipplr.com</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Tue, 09 Jun 2026 22:28:29 +0000</lastBuildDate>
    <item>
      <title>(C#) Override GetHashCode(), Equals() methods on a class. - mark4asp</title>
      <link>https://snipplr.com/view/42448/override-gethashcode-equals-methods-on-a-class</link>
      <description>&lt;p&gt;Why? So that your class can be used with collection classes.&#13;
&#13;
// basic class&#13;
&#13;
Every object has a GetHashCode() and Equals() method by default which it inherits from Object. Unfortunately these methods are useless as they stand because they say nothing specific about the class. As is, two objects of type MyStuff will only ever be equal if they are the same object (point to the same reference), making them of no use with collections.&#13;
&#13;
// useful class&#13;
&#13;
Add GetHashCode(), Equals() methods so that you can use the class with the Contains() method and other methods of IEnumerable collections.&#13;
&#13;
I stole this from Jonathan McCracken: Test-Drive ASP.NET MCV&lt;/p&gt;</description>
      <pubDate>Sun, 17 Oct 2010 18:07:55 UTC</pubDate>
      <guid>https://snipplr.com/view/42448/override-gethashcode-equals-methods-on-a-class</guid>
    </item>
  </channel>
</rss>
