首页 > 编程语言 >C#判断集合中的数据中字段的值是否都等于true

C#判断集合中的数据中字段的值是否都等于true

时间:2022-10-28 17:04:53浏览次数:34  
标签:ClassStudentList theClassStudentList C# true 中字 num ClassStudentNum public

若集合中的数据有多个字段,判断某个字段的数据的值是否都等于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

相关文章

  • C# 从死磕到精通系列 string 类型
    首先看下string类型支持的常见方法:像:1.ToString将其他类型转换为string类型。null不可转。(据说现在最新版可以支持了)    2.Split  根据指定字符切换字符串返......
  • C# webAPI +access+xadmin+layui 前端
    1.首先创建webAPI项目: 2.创建DAL类库,用户访问数据库。添加AccessHelper封装一个数据库访问类:usingSystem;usingSystem.Collections.Generic;usingSystem.Data;using......
  • 通过抹黑java等其他语言提升C# 存在感?NO NO
    今天在写业务的时候突然看到了以前封装的java库里关于java时间格式化的代码。感觉到了深深的恶意感。来一起看下java的: 还有一个合并后后的再来看一个golang的 Golang格......
  • C# UpdClient 发送16进制
    C#如何发送已知"77852563821574"这样的16进制?publicstaticbyte[]HexStringToBytes(stringhs){string[]strArr=hs.Trim(......
  • MHATC系统笔记2
    Tip:1、修改FDO.jar解决导入长期计划时,如果航路为空导入不成功问题;原来的代码是有条件删除长期计划历史库中的数据,导致从长期计划向长期计划历史库中转存数据时两个表中存在......
  • 问题定位记录1:Djano-redis库报错No connection available
    一、问题现象MANO(网络管理与编排软件)原子层创建资源后写redis缓存时报错Noconnectionavaiable堆栈打印:Traceback(mostrecentcalllast): File"/home/oes/.loca......
  • Flutter开发之Scaffold组件快速开发APP
    Scaffold包括的属性constScaffold({Key?key,PreferredSizeWidget?appBar,Widget?body,Widget?floatingActionButton,FloatingActionButtonLocation?floatingAct......
  • 智能分析网关使用教程:如何在EasyCVR视频融合平台配置告警与抓拍?
    AI智能分析网关设备内置多种深度学习算法,可支持对接入的多路视频流进行智能检测、智能识别等,包括人脸检测与识别、车辆检测与识别、车牌识别、烟火识别、安全帽识别、区域入......
  • AI车辆识别视频融合平台EasyCVR告警预案如何关联国标通道?
    在前期的文章中我们介绍了关于EasyCVR平台新增的告警预案功能及开发流程,今天我们来分享一下如何将告警预案关联国标通道。告警预案可以根据告警类型、告警级别、告警方式、......
  • centos7安装gitlab
    centos7安装gitlabgitlab下载地址 https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.7.8-ce.0.el7.x86_64.rpm 1、安装相关依赖yum-yinstal......