Find abstraction for classes which represent tables with differnt amount of colums (based on DataTables)
I can think of trying something like this.

interface ICount
{
  int count();
}

class CountOne : ICount { int count() { return 1; }}
class CountTwo : ICount { int count() { return 2; }}

abstract class IFooTable&lt;T&gt; where T : ICount, new()
{
  int count() { return (new T()).count(); }
}

class FooTable&lt;T&gt; : IFooTable&lt;T&gt;
{
  void AddRow(params object[] values) {
    assert(values.length = this.count());
    ...
  }
}

class OneTable : FooTable&lt;CountOne&gt; { }
class TwoTable : FooTable&lt;CountTwo&gt; { }


But honestly I would just expect the add function to take a row. This is not something where I'd use generics, instead I'd just use mutable data structures that have constraint checks. I'm way more concerned with column names matching especially when a params statement doesn't make sure they're in the right order.

class FooTable
{
  List&lt;string&gt; columns;
  List&lt;DataRow&gt; rows;

  void AddRow(DataRow row)
  {
    assert(column names for the row match the expected values);
    rows.add(row);
  }
}


Alternatively, you could mix both approaches. Using the generics to ensure the number of columns and then adding a DataRow at a time to enforce column names match up.