C# Generics: Constraining T where T : Object doesn't compile; Error: Constraint cannot be special class 'object'
问题 When I constrain T with : Object like this: public interface IDoWork<T> where T : Object { T DoWork(); } I get the error: Constraint cannot be special class 'object' Does that mean there is an implied difference with the following that does compile? public interface IDoWork<T> // where T : Object { T DoWork(); } 回答1: There is no difference between the two constraints, except for that one is disallowed for being useless to explicitly state. The C# 4.0 language specification (10.1.5 Type