minhhungit / ConsoleTableExt

A fluent library to print out a nicely formatted table in a console application C#
MIT License
333 stars 37 forks source link

Is this supposed to work with List<T> ? #2

Closed StingyJack closed 5 years ago

StingyJack commented 5 years ago

I've tried a few permutations, but I cant get it to accept a list of the same type objects.

like


public class MyClass 
{
  public string StringValue1 {get;set;}
  public string StringValue2 {get;set;}
  public string StringValue3 {get;set;}
}

var t1 = new MyClass {StringValue1 = "1", StringValue2 = "2", StringValue3 = "3"};
var t2 = new MyClass {StringValue1 = "4", StringValue2 = "5", StringValue3 = "6"};

var tList = new List<MyClass>{t1, t2}

ConsoleTableBuilder.From(tList) //<-- wont compile.
minhhungit commented 5 years ago

@StingyJack You have to convert MyClass to List<object> object is value which you want to show on cell, it can be string, number

for example:

static List<List<object>> SampleListData = new List<List<object>>
{
   new List<object>{ "Sakura Yamamoto", "Support Engineer", "London", 46},
   new List<object>{ "Serge Baldwin", "Data Coordinator", "San Francisco", 28, "something else" },
   new List<object>{ "Shad Decker", "Regional Director", "Edinburgh"},
};
minhhungit commented 5 years ago

@StingyJack Thank you for your PR, now we support List<List<T>> type