获取dictionary 值连续相同的索引,

 

            for (int i = 0; i < 24;)
            {
                var cell = table2[1, i];
               
                var rangType = companyScheme[i];
                string txtCell = "";
                switch (rangType)
                {
                    case 1: txtCell = ""; break;
                    case 2: txtCell = ""; break;
                    case 3: txtCell = ""; break;
                    case 4: txtCell = ""; break;
                }
                cell.AddParagraph().AppendText(txtCell);

                int end = DD(i, companyScheme);
                table2.ApplyHorizontalMerge(1, i, end);
                i += end - i + 1;
            }

 

public static int DD(int i, Dictionary<int, int> companyScheme)
{
if(i == 23)
{
return 23;
}

if(companyScheme[i]== companyScheme[i + 1])
{
return DD( i +1, companyScheme);
}
else
{
return i;
}
}

 

posted @ 2019-04-30 09:52  zklve2  阅读(238)  评论(0编辑  收藏  举报