IComparable<> inheritance in SortedDictionary

public void Test()
  var dic = new SortedDictionary<BaseClass, string>();
  dic.Add(new BaseClass(){Number = 1}, "");
  dic.Add(new ExtendClass(){Text = "One"}, "");
  Assert.True(dic.ContainsKey(new BaseClass() { Number = 1 }));
  Assert.False(dic.ContainsKey(new BaseClass() { Number = 2 }));
  Assert.True(dic.ContainsKey(new ExtendClass() { Text = "One" }));
  Assert.False(dic.ContainsKey(new ExtendClass() { Text = "Two" }));
public class BaseClass : IComparable<BaseClass>
  public int Number { get; set; }
  public virtual int CompareTo(BaseClass other)
    return Number.CompareTo(other.Number);
public class ExtendClass : BaseClass, IComparable<ExtendClass>
  public string Text { get; set; }
  public override int CompareTo(BaseClass other)
    var other2 = other as ExtendClass;
    return other2 == null ? base.CompareTo(other) : CompareTo(other2);
  public int CompareTo(ExtendClass other)
    return Text.CompareTo(other.Text);


  1. Bovada is a top-notch platform that qualifies as one of the best online on 카지노 사이트 line casino throughout varied categories. The casino’s slots division boasts high RTP and distinctive titles. Other promos embody a 5% crypto increase, $1,000,000 in month-to-month prizes for slots gamers, the Ultimate Spin-Off $5,000 weekly slots tournament, and extra. You can use nine different banking strategies, together with crypto and conventional cost options. Specifically, have the ability to|you probably can} opt for MasterCard, Visa, American Express, Player Transfer, or examine by courier.


Post a Comment

Popular posts from this blog

Parse XML to dynamic object in C#

Parse XML to object model in C# using XSD utility