C#检测DataSet/DataTable是否为空的方法

  //C#检测DataSet是否为空的方法 
     DataSet ds = new DataSet();
            if (dt.Tables.Count > 0) 
            {
                //有数据
            }
            else((ds.Tables.Count==1&&ds.Tables[0].Rows.Count==0)||ds==null||ds.Tables.Count==0)
            {
               //无数据
            }
   // C#检测DataTable是否为空的方法 
            DataTable dt = new DataTable();
            if (dt.Rows.Count > 0)
            {
                //不为空的操作
            }
            else (dt == null || dt.Rows.Count == 0)
            {
                //为空操作
            }

 

posted @ 2021-08-26 22:11  大木瓜  阅读(2126)  评论(0编辑  收藏  举报