最佳答案
class ResultBase {}
class Result : ResultBase {}
Task<ResultBase> GetResult() {
return Task.FromResult(new Result());
}
The compiler tells me that it cannot implicitly convert Task<Result>
to Task<ResultBase>
. Can someone explain why this is? I would have expected co-variance to enable me to write the code in this way.