c# - .Net Reformat data in the List of List of Sting -


i have list(of list(of string).

list contains data this:

item-a1 item-a2 item-a3 item-b1 item-b2 item-b3 item-c1 item-c2 item-c3 

i somehow change this:

item-a1 item-b1 item-c1 item-a2 item-b2 item-c2 item-a3 item-b3 item-c3 

is there way reformat data , shown in example ? hints appreciated!

            list<list<string>> lststrings = new list<list<string>>{                new list<string>() {"a1","a2","a3"},                new list<string> {"b1","b2","b3"},                new list<string> {"c1","c2","c3"}                 };                 list<list<string>> newlist = new list<list<string>>();                 int j=0;                  foreach(string s in lststrings[0])                  {                       list<string> innerlist = new list<string>();                      for(int i=0;i<lststrings.count;i++)                     {                         innerlist.add(lststrings[i][j]);                         }                     j++;                     newlist.add(innerlist);             }             foreach(list<string> lstinner in newlist)             {                 foreach(string s in lstinner)                 {                     console.write(s);                     }                 console.writeline();             } 

output

a1b1c1

a2b2c2

a3b3c3


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -