给定一张表格,判断其中哪些字段下的数据有重复值
Hashtable ht = new Hashtable();
for (int u = 0; u < uniquesz.Length; u++)
{
for (int i = 0; i < rows.Count; i++) //循环获取该字段下的所有数据
{
Hashtable row1 = (Hashtable)rows[i];
ht.Add(i, row1[uniquesz[u]]);
}
bool result = IsRepeat(ht);
if (!result) {
zdcf += "'" + uniquesz[u] + "' ";//拼接重复的字段
}
ht.Clear();
}
}
#region<--判断字段中的数据是否有重复-->
public bool IsRepeat(Hashtable ht)
{
Hashtable ht1 = new Hashtable();
for (int i = 0; i < ht.Count; i++)
{
if (ht1.ContainsValue(ht[i]))
{
return true;
}
else {
ht1.Add(i, ht[i]);
}
}
return false;
}
#endregion