获取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;
}
}
原文地址:https://www.cnblogs.com/kunlunmountain/p/10794342.html