c# - Create Datatable from a list of column values -
I am trying to create a database with the following lists
** list1 * * 1 2 3 4 5 ** list 2 ** foo1 foo2 foo3 foo4 foo5 The last table should look like this (not the name of the colonel's name)
I am trying to avoid referring to the respective indexes of both lists and adding them as rows; Somnath 1 Somnath 2 1 foo1 2 foo2 3 foo3 4 foo4 5 foo5
Is there a way to do this? The way is the way?
Edit: I can not have any list which is just 2
It will work with any number of IEmarebal.
Private static zero main (string [] arg) {var list1 = new list & lt; Int & gt; (New [] {1, 2, 3, 4, 5}); Var list2 = new list & lt; String & gt; (New [] {"foo1", "foo2", "foo3", "foo4", "foo5"}); Var list3 = new list & lt; Bool & gt; (New [] {true, false, truth, truth, wrong}); Var dt = MakeDataTable (list1, list2, list3); Console.ReadLine (); } Private Static Datable MacDataTable (Parameters IEnumerable [] lists) {var dt = new DataTable (); (Var i = 0; i & lt; lists; length; i ++) {dt.Columns.Add ("column" + i); } Foreach (different data in CombineList) {dt.ows.Add (data); } Return DT; } Private Stable IEnumerable & lt; Object [] & gt; CombineList (Parameters IEnumerable [] lists) {var enumerators = lists.Select (l => gtg.GetEnumerator ()). ToArray (); While (calculator. All (E = & gt; E. MeNext ())) {yield returns enumerator. Selection (E = & gt; E. Current) .Oir (); }}
Comments
Post a Comment