Link to home
Start Free TrialLog in
Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America

asked on

C# Best Practice: List<T> of List<T> or List< List<T>> -- better way?

I know you can have a List< List<T> >.  But there is something about it that seems strange to me.

What I am wanting is to have a TableClass which has a List < Row Class >.   Each Row Class is a List< Cell Class >.

Is there a nicer / cleaner way to represent this other than:

TableClass<RowClass<CellClass>>

In other words:

  public class TableClass
    {
        public TableClass() { }

        public List<RowClass> Rows { get; set; }
    }

    public class RowClass
    {
        public RowClass() { }

        public List<CellClass> Cells { get; set; }
    }
    public class CellClass
    {
        public CellClass() { }        
    }

Open in new window



Better way?
SOLUTION
Avatar of p_davis
p_davis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It is not clear what you wish to accomplish and I am wondering if you are not trying to re-invent the wheel here, for example a DataTable object?
Avatar of Tom Knowlton

ASKER

p_davis:

Not a bad idea.

Fernando Soto:

I know about DataTables.  I kind of [want] something like a DataTable - but not nearly as heavy in methods and features .. just basic navigation and querying, with a few additional attributes for my purposes.


Maybe it is a dumb question.  I just think   List<List<T>>    is kind of hookey - inelegant.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial