I want to check if under column "name" is there any same value. If yes so i want to check if the next same value > Bit + Size. I can do it with 2 for loops but what i want is something more simple. Can anyone show me how?
My DataTable:
name Bit Size
m1 8 3
m0 9 5
m1 10 2 // Error, should be 11
m2 11 4
My code:
for(int i = 0; i <= Dt.Rows.Count - 1; i++)
{
for(int y = i +1; y <= Dt.Rows.Count - 1, y++ )
{
if(Dt.Rows[i]["name"].ToString() == Dt.Rows[y]["Name"].ToString())
if( (Convert.ToInt32(Dt.Rows[i]["Bit"].ToString()) + Convert.ToInt32(Dt.Rows[i]["Size"].ToString()) > (Convert.ToInt32(Dt.Rows[y]["Bit"].ToString()) ) )
{
// Show Error
MessageBox.Show("Error");
Dt.Rows[y]["Bit"] = Dt.Rows[i]["Bit"];
}
}
}