代码如下,判断两个List是否相等:public bool CompareSequenceList<T>(List<T> source, List<T> target)
{
bool res = true;
if (source.Count != target.Count)
res = false;
else
{
for (int i = 0; i < source.Count; i++)
{
if (source[i] == target[i])
{
res = false;
break;
}
}
}
return res;
}编译提示:source[i] == target[i]出错,==运算符无法比较
我要比较的值有可能是int,double,Enum...等, 如何在方法后加对应的约束;代码用的.net framework2.0框架,无法用Linq...
{
bool res = true;
if (source.Count != target.Count)
res = false;
else
{
for (int i = 0; i < source.Count; i++)
{
if (source[i] == target[i])
{
res = false;
break;
}
}
}
return res;
}编译提示:source[i] == target[i]出错,==运算符无法比较
我要比较的值有可能是int,double,Enum...等, 如何在方法后加对应的约束;代码用的.net framework2.0框架,无法用Linq...
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货