Use list to check for duplicates in a datarow


If you are walking through a dataset or datarow printing things out, you can skip duplicates by using a list to keep track of what you have done so far.

var dupcheck = new List<string>();
foreach (DataRow dr in dt.Rows)
     string partNumber = dr[1]+"";
     if(dupcheck.Contains(partNumber)) continue;		//skip duplicate
     //print out the partnumber 


Leave a Comment