c# - How to: Join 2 DataTables with same Row Count -


i've got these 2 datatables:

table1: columns->"timestamp1,result1" row[0]->"sometime,someresult"

table2: columns->"timestamp2,result2" row[0]->"someothertime", "someotherresult"

now want result table or string[] or string this:

table result: columns->"timestamp1,result1,timestamp2,result2" row[0]->"sometime,someresult,someothertime,someotherresult"

is there simple way of doing this? if tables got more rows one?

i've allready got solution joining columns string:

stringbuilder sb = new stringbuilder();          foreach (datatable dt in data_set.tables)         {             sb.append(string.join(",", dt.columns.cast<datacolumn>().select(x => x.columnname).toarray()));             sb.append(",");                                       } 

output example tables string >> "timestamp1, result1,timestamp2,result2"

so using linq possible, unfortunately dont it...

could me please?

best regards

edit:

both tables should have same count of rows! merge not work, because not join 1 rows 2 different tables new single one. merge output 2 rows in new table.

from both tables, below result table :

var resulttable = t1 in datatable1.asenumerable()                  join t2 in datatable2.asenumerable()                       on t1.field<int>("id") equals t2.field<int>("id")                  select new { t1, t2 }; 

then after apply logic on resulttable getting result


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -