Tag: icomparablet

带有generics的C#boxing枚举错误

我不明白这里发生了什么…… 我有以下错误: 类型’TestApp.TestVal’不能用作generics类型或方法’TestApp.SomeClass’中的类型参数’T’ ‘TestApp.SomeClass’ 。 没有从’TestApp.TestVal’到’System.IComparable’装箱转换。 以下代码发生此错误: public enum TestVal { First, Second, Third } public class SomeClass where T : IComparable { public T Stored { get { return storedval; } set { storedval = value; } } private T storedval; } class Program { static void Main(string[] args) { //Error is on the […]