DataTableMerger

This is a class written in .NET 2.0 (C#).

The class takes in two DataTable objects, and returns one, merged DataTable object. The merge works on finding common values in one or more shared columns. Here's an example.

  • We have a table, lets call it Table 1



  • We have another table, lets call it Table 2. We wish to merge the two tables. You'll notice that both tables have the 'City' column. We'll merge any row in Table 1 with a corresponding row in Table 2 - where they share the same 'City' value.



  • Here's the resulting, merged table. Notice that, as 'Paris' doesnt appear in Table 2, 'Bob' isnt in the merged table.



Usage: DataTable MergedTable = DataTableMerger.Merge(table1, table2);

Download the file: DataTableMerger.cs