C# table rows and columns
What object can I use that has rows and columns, but not DataTable as it looks 开发者_JAVA技巧like an Excel Table?
I would use BindingList<T>
or List<T>
. BindingList would get my vote, as it is essentially a List with some extra options that enable it to be bound to a datagridview or Listbox very easily. And it is more light-weight than a DataTable.
Your rows will be each item in the list, and your columns will be the properties of each object that you bind to your viewer, such as a datagridview. I used this recently with a BindingList and it went very well.
Ultimately your options are these:
- Multidimensional array:
a[i,j] = value
- Jagged array:
a[i][j] = value
- Indexed array:
a[i+N*j] = value
Most other classes that I can think of, wrap one of these types of arrays.
精彩评论