//创建DataTable

DataTable dt=new DataTable("tbAmount");
     dt.Columns.Add("riqi",System.Type.GetType("System.String"));
     dt.Columns.Add("bianm",System.Type.GetType("System.String"));
     dt.Columns.Add("xAmount",System.Type.GetType("System.String"));
     dt.Columns.Add("jPoints",System.Type.GetType("System.String"));

//把数据读到DataTable中
     while((input=f.ReadLine())!=null)     
     {
      if(input.Trim()=="")
       continue;
      asF=input.Split(",".ToCharArray());
      DataRow drw=dt.NewRow();
      drw["riqi"]=asF[0].Trim();
      drw["bianm"]=asF[1].Trim();
      drw["xAmount"]=asF[2].Trim();
      drw["jPoints"]=asF[3].Trim();
      dt.Rows.Add(drw);
     }

//for循环比较DataTable中的数据
     for(int i=1;i<dt.Rows.Count;i++)
     {
      string cola=dt.Rows[i][0].ToString();
      string colb=dt.Rows[i][1].ToString();
      for(int j=i+1;j<dt.Rows.Count;j++)
      {
       string colc=dt.Rows[j][0].ToString();
       string cold=dt.Rows[j][1].ToString();
       if(cola==colc&&colb==cold)
       {
        iErrorCount++;
        output="*"+","+cola+","+colb+",存在相同行的数据\r\n";
        myOutput.Add(output);
       }

      }
     }

相关文章:

  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2021-12-05
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案