public IList<IList<int>> FunctionName(...)
{
var list = new List<List<int>>();
...
//return list; // This doesn't compile (error listed below)
return (IList<IList<int>>)list; // Explicit cast compiles
}
Run Code Online (Sandbox Code Playgroud)
当我直接返回"list"时,我收到此错误:
> "Cannot implicitly convert type
> 'System.Collections.Generic.List<System.Collections.Generic.List<int>>'
> to
> 'System.Collections.Generic.IList<System.Collections.Generic.IList<int>>'.
> An explicit conversion exists (are you missing a cast?)"
Run Code Online (Sandbox Code Playgroud)
接口返回类型不应该接受任何派生实例吗?