当调用任何转换函数错误出现时:
Argument 2: cannot convert from 'System.Collections.Generic.List<T>' to 'System.Collections.Generic.List<ProductionRecent>
我试图在函数内传递任何列表,确定它必须是哪个列表并转换它。有什么建议?
public List<T> ConvertToList<T>(DataTable dt, List<T> list)
{
if (list.GetType() == typeof(List<ProductionPending>))
{
ConvertToProductionPending(dt, list); // ERROR
}
else if (list.GetType() == typeof(List<ProductionRecent>))
{
ConvertToProductionRecent(dt, list); // ERROR
}
else if (list.GetType() == typeof(List<MirrorDeployments>))
{
ConvertToMirror(dt list); // ERROR
}
return list;
}
private List<ProductionPending> ConvertToProductionPending(DataTable dt, List<ProductionPending> list)
{
// do some stuff here
return list;
}
private List<ProductionRecent> ConvertToProductionRecent(DataTable dt, List<ProductionRecent> list)
{
// do some stuff here
return list;
}
private List<MirrorDeployments> ConvertToMirror(DataTable dt, List<MirrorDeployments> list)
{
// do some stuff here
return list;
}
阿晨1998
相关分类