为什么这会给我一个编译时错误Cannot convert 'ListCompetitions' to 'TOperation'
:
public class ListCompetitions : IOperation
{
}
public TOperation GetOperation<TOperation>() where TOperation : IOperation
{
return (TOperation)new ListCompetitions();
}
然而这是完全合法的:
public TOperation GetOperation<TOperation>() where TOperation : IOperation
{
return (TOperation)(IOperation)new ListCompetitions();
}