First, get rid of the DataTable for those counts of data. Its memory usage is way to huge here.
If your data are always 0/1, the most efficient way should be a bit-mask.
If your data are not only 0/1, create a structure that abstracts all your columns.
Here's a conceptional prototype of that data structure.
class MyData {
public MyData(int[] columns, object[] data) {
_columns = columns;
_data = data;
}
int[] _columns;
object[] _data;
public object this[int column] {
get {
int index = IndexOf(column);
return index != -1 ? _data[index] : null;
}
}
private int IndexOf(int column) {
for (int i = 0; i < _columns.Length; i++)
if (_columns[i] == column)
return i;
return -1;
}
}
You could additionally save the memory for the _columns by applying the flyweight pattern.
Hope this helps