DataTable dt = new DataTable();
dt.Columns.Add("f");
dt.Columns.Add("t");
DataRow row = dt.NewRow();
row[0] = "aa";
row[1] = "10";
dt.Rows.Add(row);
row = dt.NewRow();
row[0] = "bb";
row[1] = "20";
dt.Rows.Add(row);
row = dt.NewRow();
row[0] = "cc";
row[1] = "20";
dt.Rows.Add(row);
row = dt.NewRow();
row[0] = "aa";
row[1] = "15";
dt.Rows.Add(row);
row = dt.NewRow();
row[0] = "bb";
row[1] = "-10";
dt.Rows.Add(row);
DataTable dtTemp = dt.Clone();
for(int i=0; i<dt.Rows.Count;i++)
{
DataRow[] rrow = dtTemp.Select("f=''"+dt.Rows[i]["f"].ToString()+"''");
if(rrow.Length > 0)
{
dtTemp.Select("f=''"+dt.Rows[i]["f"].ToString()+"''")[0][1] = int.Parse(dtTemp.Select("f=''"+dt.Rows[i][0].ToString()+"''")[0][1].ToString()) + int.Parse(dt.Rows[i][1].ToString());
dtTemp.AcceptChanges();
}
else
{
DataRow dr = dtTemp.NewRow();
dr[0] = dt.Rows[i][0].ToString();
dr[1] = dt.Rows[i][1].ToString();
dtTemp.Rows.Add(dr);
}