title: Using incremental number as GetHashCode return value
body: <p>I want to make every instance of a class <code>X</code> having a unique ID.<br>
  I'm doing this using a incremented number:</p>
  
  <pre><code>class X {
      private int id;
      private static int instanceCounter = 0;
  
      public X() {
          id = Interlocked.Increment(ref instanceCounter);
      }
  
      //...
  }
  </code></pre>
  
  <p>The objects are also used as keys in dictionaries, so I thought I could return <code>id</code> from <code>GetHashCode()</code>.</p>
  
  <pre><code>    public override int GetHashCode() {
          return id;
      }
  </code></pre>
  
  <p>I'm aware of <a href="http://blogs.msdn.com/b/ericlippert/archive/2011/02/28/guidelines-and-rules-for-gethashcode.aspx" rel="nofollow">Eric Lippert's post</a>, but it always talks about calculating hashs from multiple data stored in the object.<br>
  In my case, the only 'unique' data is <code>id</code>.</p>
  
  <p><strong>So the question is:<br>
  Is there something I haven't thought about with this approach?</strong></p>