在下面的代码编译错误发生但我无法理解原因。
class RealMock<TEntity> : DataContext
{
public RealMock():base("")
{
}
public List<TEntity> inMemoryDataStore = new List<TEntity>();
public List<TEntity> GetTable<TEntity>() where TEntity : class
{
return inMemoryDataStore; //Compilation error
}
}
无法将类型'System.Collections.Generic.List [c:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ mscorlib.dll]'隐式转换为'System.Collections.Generic .List [c:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ mscorlib.dll]'
答案 0 :(得分:2)
我相信这是因为参数化的GetTable方法,尝试将其定义为
public List<TEntity> GetTable () {...}