日期:2014-05-17  浏览次数:20752 次

求个算法!!亲
List<<List<T>>如何行专列



如上图,Excel按行读取,读出来的数据是

按行读取,List<string> 并且添加到List<List<string>>中。

类似于这个操作


 var lst0 = new List<string> { "HJ00RY001-CB04", "6903148048801", "6920177916161", "6924882335385", "6924882335514" };
            var lst1 = new List<string> { "", "HJ00RY001-CB04-HW01", "HJ00RY001-CB04-HW02", "HJ00RY001-CB04-HW03", "HJ00RY001-CB04-HW04" };
            var lst2 = new List<string> { "", "30", "30", "30", "30" };
            var lst3 = new List<string> { "", "30", "30", "30", "30" };
            var lst4 = new List<string> { "", "40", "40", "40", "40" };
            var lst5 = new List<string> { "", "48000", "48000", "48000", "48000" };
            var lst6 = new List<string> { "", "4", "4", "4", "4" };
            var lstData = new List<List<string>> {lst0, lst1, lst2, lst3, lst4, lst5, lst6};


如果把List<List<string>> lstData 这里的数据行专列

期望LstData里的数据是

List[0]{"HJ00RY001-CB04","","","","","",""}
List[1]{"6903148048801","HJ00RY001-CB04-HW01","30","30","40","48000","4"}

……

求算法


------解决方案--------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var lst0 = new List<string> { "HJ00RY001-CB04", "6903148048801", "6920177916161", "6924882335385", "6924882335514" };
            var lst1 = new List<string> { "", "HJ00RY001-CB04-HW01", "HJ00RY001-CB04-HW02", "HJ00RY001-CB04-HW03", "HJ00RY001-CB04-HW04" };
         &