I need to eliminate all rows that contain either string notUsed
or string notUsed2
, where a particular identity is 2.
I'm using a foreach loop to accomplish this, prior to appending any of my data to a stringbuilder.
I would have chosen a method like so:
foreach (DataRow dr in ds.Tables[0].Rows)
{
int auth = (int)dr[0];
if (auth == 2) continue;
string notUsed = "NO LONGER USED";
string notUsed2 = "NO LONGER IN USE";
if (dr.Cells[3].ToString().Contains(string)notUsed)
{
dr.Delete();
}
else
{
if (dr.Cells[3].ToString().Contains(string)notUsed2)
{
dr.Delete();
}
}
}
However, the above is... utterly wrong. It seems logical to me, but I don't quite understand how to form that method in a way that C# understands.