若集合中的数据有多个字段,判断某个字段的数据的值是否都等于true。
加一个数值计算列表中的个数,每判断完一项,其数值加一,当数值达到列表中数据的个数时,就判断完成了。
例如:
public class ClassStudent
{
public bool status = false;
public OneStudent student= null;
public Dictionary<string, bool> theStudentStatus = new Dictionary<string, bool>();
public bool studenthasclass=false ;
}
public class ClassStudentList: List<ClassStudent>
{
}
判断
foreach (string studentID in studentsID)
{
int num = 0;
ClassStudentList theClassStudentList = new ClassStudentList();
for ( int ClassStudentNum = 0 ; ClassStudentNum < theClassStudentList.Count ; ClassStudentNum ++)
{
if ( theClassStudentList [ClassStudentNum ] . theStudentStatus [studentID] == true)
{
num = num+1;
}
}
if ( num == ClassStudentList.Count)
{
theClassStudentList [ClassStudentNum ] . studentHasClass = true;
}
}
标签:ClassStudentList,theClassStudentList,C#,true,中字,num,ClassStudentNum,public From: https://www.cnblogs.com/Joyce-mi7/p/16836632.html