title: ArgumentException: element already exists in SortedSet
body: <p>I am having some problem using SortedList in C# (I am working on Unity 5.0.3 with Visual Studio 2015). I have two classes ScoreKey and Score. ScoreKey implements IComparable. </p>
  
  <p>But when I try to add entry to the SortedList I get the error </p>
  
  <pre><code>ArgumentException: element already exists
  System.Collections.Generic.SortedList`2[ScoreKey,Score].PutImpl (.ScoreKey key, .Score value, Boolean overwrite)
  </code></pre>
  
  <p>I can't figure out why I am getting this error. I am using instances of an class as key so there is no chance of having the same key, right? Here is the code.</p>
  
  <p><strong>Class Definitions:</strong></p>
  
  <pre><code>public class ScoreKey : IComparable
  {
      public uint val;
      public uint timestamp;
      public int CompareTo(object obj)
      {
          ScoreKey s2 = obj as ScoreKey;
          if (s2.val == val)
          {
              return timestamp.CompareTo(s2.timestamp);
          }
          return val.CompareTo(s2.val);
      }
  }
  [System.Serializable]
  public class Score
  {
  
      public ScoreKey key;
      public uint val
      {
          get { return key.val; }
      }
      string user;
      public uint timestamp
      {
          get
          {
              return key.timestamp;
          }
      }
      public Score(string _user, uint _score)
      {
          key = new ScoreKey();
          key.timestamp = GetUTCTime();
          user = _user;
          key.val = _score;
      }
  }
  </code></pre>
  
  <p><strong>Test Code:</strong></p>
  
  <pre><code>SortedList&lt;ScoreKey, Score&gt; scoreList = new SortedList&lt;ScoreKey, Score&gt;();
  Score[] scores = {
      new Score("Bishal", 230),
      new Score("Bishal", 3456),
      new Score("Bishal", 230),
      new Score("Bishal", 123),
      new Score("Bishal", 86),
      new Score("Bishal", 4221)
  };
  for(int i = 0; i&lt; scores.Length; i++)
  {
      Debug.Log(scores[i].pretty);
  
      scoreList.Add(scores[i].key, scores[i]);
  }
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>**GetUTCTime Function: **</p>
  
  <pre><code>public static uint GetUTCTime()
  {
     return (uint)(System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1))).TotalSeconds;
  }
  </code></pre>