美文网首页
C#的学习笔记

C#的学习笔记

作者: abigale_gd | 来源:发表于2018-05-22 09:52 被阅读0次

    两种循环方法

     List<string> list = new List<string>();
     List<string> listString = new List<string>();
    foreach (DataRow dr in dt.Tables[0].Rows)
                {
                    string mddj = dr["mdid"].ToString().Trim() + dr["djid"].ToString().Trim();
                    if (!list.Contains(mddj))
                    {
                        list.Add(mddj);
                    }
                };
                foreach (string eachString in list)
                {
                    string md = eachString.Substring(0, 2);
                    string dj = eachString.Substring(2);
                    DataRow[] dr = dt.Tables[0].Select("mdid='" + md + "' and djid = '"+dj+"'");
    
                    DataTable dtt_single = dr[0].Table.Clone();  // 复制DataRow的表结构
                    foreach (DataRow row in dr)
                    {
                         dtt_single.ImportRow(row);
                         dtt_single.Rows.Add(row);  // 将DataRow添加到DataTable中
                    }
    
    var dtt_single = dt.Tables[0].Where(row => row.Field<string>("mdid").Equals(md) && row.Field<string>("djid").Equals(dj));
    dtt_single.TableName = eachString;
    ds_all.Tables.Add(dtt_single);
                }
    

    对象写法

      dataJson.forEach(function (v, i) {
                  barData[v.mdid + v.djid] = {};
                  barData[v.mdid + v.djid]["TotalCount"] = v.TotalCount;
                  barData[v.mdid + v.djid]["BCount"] = v.BCount;
                  barData[v.mdid + v.djid]["CurrCount"] = v.CurrCount;
                  barData[v.mdid + v.djid]["djname"] = $.trim(v.djname);
               })
     for (var item in barData) {
              barDataArr.push(barData[item]);
               }
     barDataArr.sort(function (a, b) {
              return b["TotalCount"] - a["TotalCount"];
             })
     xAxis = Object.keys(barData)

    相关文章

      网友评论

          本文标题:C#的学习笔记

          本文链接:https://www.haomeiwen.com/subject/ovthjftx.html