Write a program for concat to create one sequence of data rows that contains datatabless data rows, one after the other?
Answer Posted / Poojatyagi
{"C# LINQ example using Concat method:n```csharpnvar dataTable1 = new DataTable(); // data table 1nvar dataTable2 = new DataTable(); // data table 2nDataRow[] rows1 = { dataTable1.NewRow(), dataTable1.NewRow() }; // creating some sample rows for data table 1nDataRow[] rows2 = { dataTable2.NewRow(), dataTable2.NewRow() }; // creating some sample rows for data table 2nrows1[0]["Column1"] = "Value1"; rows1[0]["Column2"] = "Value2"; // setting values for the first row of data table 1nrows1[1]["Column1"] = "Value3"; rows1[1]["Column2"] = "Value4"; // setting values for the second row of data table 1nrows2[0]["Column1"] = "Value5"; rows2[0]["Column2"] = "Value6"; // setting values for the first row of data table 2nrows2[1]["Column1"] = "Value7"; rows2[1]["Column2"] = "Value8"; // setting values for the second row of data table 2ndataTable1.Rows.AddRange(rows1); // adding rows to data table 1ndataTable2.Rows.AddRange(rows2); // adding rows to data table 2nvar combinedData = dataTable1.AsEnumerable().Concat(dataTable2.AsEnumerable());n```}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
No New Questions to Answer in this Category !! You can
Post New Questions
Answer Questions in Different Category