Stack<T> radioHidenArch = new Stack<T>();//栈用来保存单选问题和复选框问题*****//
foreach (var model in list)
{
#region 移除未选中的单选、复选问题子项
// 满足两个条件:1.是单选或者复选下的选项 2.该单选或者复选为没有选中状态 则continue
if (radioHidenArch.Count != 0 && model.ItemDepth
> radioHidenArch.Peek().ItemDepth &&
(radioHidenArch.Peek().ItemFlag == false))
continue;//判断是否是单选或者复选问题下的选项
while (radioHidenArch.Count != 0 && model.ItemDepth <= radioHidenArch.Peek().ItemDepth)//Peek()为取值
{
radioHidenArch.Pop();//移除
}
//当选项为复选框时控制div的隐藏和显示 Id为div+选项的ID
if (model.ItemType == 1) //单选问题
{
//单选问题入栈
radioHidenArch.Push(model);//插入
}
else if (model.ItemType == 2)//复选框
{
radioHidenArch.Push(model);//复选框入栈
}
#endregion
}