I have the following interface that returns the generic parameter of type T using a callback...
public interface IDoWork
{
T DoWork();
}
Unfortunately, they can't be combined.
You can see this in the framework - that's why there is a separate Task and Task<T> class, for example.
That being said, you can often share implementations in this type of scenario by using IDoWork<object>
and passing null
for values, etc.
return type is a part of method signature, so T DoWork() and void DoWork() are different, and void is not a type and it is not a null
. It is an indication there is nothing in evaluation stack on return from method.