Create Generic Function for any type of list injection#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
DataFrameShowTable<T>(List<T>items){varproperties=typeof(T).GetProperties();List<DataFrameColumn>columns=new();foreach(stringheaderinproperties.Select(p=>p.Name)){columns.Add(newStringDataFrameColumn(header,newList<string>()));// Read as string}foreach(variteminitems){for(inti=0;i<properties.Length;i++){varvalues=properties.Select(p=>p.GetValue(item)?.ToString()??"").ToList();((StringDataFrameColumn)columns[i]).Append(values[i]);}}returnnewDataFrame(columns);}
Simply call the function in next cell without any commas or stuff#