为什么DoesntWork()不能在下面工作呢?错误是:Cannot implicitly convert type 'List' to 'IEnumerable'. An explicit conversion exists (are you missing a cast?)。我知道这与我没有得到的泛型/模板有关,但是List是IEnumerable,实现者是IInterface。我不明白为什么这需要抛出(或者如果它真的可以)。
public interface IInterface
{
// ...
}
public class Implementer : IInterface
{
// ...
}
IEnumerable<IInterface> DoesntWork()
{
List<Implementer> result = new List<Implementer>();
return result;
}https://stackoverflow.com/questions/3028928
复制相似问题