// 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();
}
问题:在测试中发生以下错误。什么可以成为铸造的解决方案?明确铸造问题
不能将类型'AContainer'隐式转换为'IContainer'。一个显式转换存在(是否缺少强制转换?)
这个问题似乎要拿出大部分时间。发帖前是否搜索过? – thecoop 2009-09-18 09:10:28