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();
}
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 parameter constraints) says two things about this:
In your comment, you said that you were trying to make
Tbe of typeVoid.Voidis a special type that indicates that there is no return type and cannot be used in place ofT, which requires an appropriate concrete type. You will have to create a void version of your method and aTversion if you want both.