// The Structure of the Container and the items
public interface IContainer <TItem> where TItem : IItem
{
}
public class AContainer : IContainer<ItemA>
{
}
public interface IItem
{
}
public class ItemA : IItem
{
}
// Client app
[Test]
public void Test ()
{
IContainer<IItem> container = new AContainer();
}
问:在测试下面的错误occures。 有什么可以用于铸造的解决方案吗?
无法隐式转换类型“的aContainer”到“的IContainer”。 一个显式转换存在(是否缺少强制转换?)