我希望能够在我的数据表中检测到2个相似的字符串。我该怎么办?
foreach (DataRow row2 in visualDataTable.Rows)
{
foreach (char server in serverName)
{
foreach(similar string in servername)
{
// do something..
}
}
}
答案 0 :(得分:0)
最简单的方法将涉及遍历您的行两次,并将每个值相互比较(类似于上述方法):
foreach (DataRow row in visualDataTable.Rows)
{
foreach (DataRow compareRow in visualDataTable.Rows))
{
if(row["<your column>"] == compareRow["<your column>"])
{
// The two rows have the same column value for <your column>
// Do something
}
}
}