refer this and customize for your need
static void Main(string[] args)
{
DataTable ds1 = new DataTable();
ds1.Columns.Add("CommonCol");
ds1.Columns.Add("Col2");
ds1.Columns.Add("Col3");
ds1.Rows.Add("A", 1, 2);
ds1.Rows.Add("B", 1, 2);
DataTable ds2 = new DataTable();
ds2.Columns.Add("CommonCol");
ds2.Columns.Add("Col2");
ds2.Columns.Add("Col3");
ds2.Rows.Add("A", 1, 2);
DataTable ds3 = new DataTable();
ds3.Columns.Add("CommonCol");
ds3.Columns.Add("Col2");
ds3.Columns.Add("Col3");
ds3.Rows.Add("A", 1, 2);
DataTable ds4 = new DataTable();
ds4.Columns.Add("CommonCol");
ds4.Columns.Add("Col2");
ds4.Columns.Add("Col3");
ds4.Rows.Add("A", 1, 2);
DataTable ds5 = new DataTable();
ds5.Columns.Add("CommonCol");
ds5.Columns.Add("Col1");
ds5.Columns.Add("Col2");
ds5.Columns.Add("Col3");
ds5.Columns.Add("Col4");
ds5.Columns.Add("Col5");
foreach (DataRow row in ds1.Rows)
{
string common = row["CommonCol"].ToString();
double ds1col2 = GetValue(common, ds1);
double ds2col2 = GetValue(common, ds2);
double ds3col2 = GetValue(common, ds3);
double ds4col2 = GetValue(common, ds4);
double total = ds1col2 + ds2col2 + ds3col2+ ds4col2;
var newRow = ds5.NewRow();
newRow["CommonCol"] = common;
newRow["Col1"] = ds1col2;
newRow["Col2"] = ds2col2;
newRow["Col3"] = ds3col2;
newRow["Col4"] = ds4col2;
newRow["Col5"] = total;
ds5.Rows.Add(newRow);
}
}
static double GetValue(string common, DataTable dt) {
double returnValue = 0;
var rows = dt.Select("CommonCol = '" + common + "'");
if (rows.Length > 0)
double.TryParse(rows[0]["Col3"].ToString(), out returnValue);
return returnValue;
}