
上QQ阅读APP看书,第一时间看更新
Introducing constraints
To compare values, you want to use the CompareTo method. It can be used if you have where T : IComparable. This is a new construct there. It's a constraint. The Compare method works, but it only does so if the data type on which it is operating has IComparable implemented on it. In other words, it makes sense to compare the values.