DataSet ds = DBHelp.DateSet(strSql.ToString());
            int count = Store.Tables[0].Rows.Count;
            if (ds.Tables[0].Rows.Count > 0)
            {
                string[] SingleStore = null;
                for (int yy = 0; yy < count; yy++)
                {
                    if (Store.Tables[0].Rows[yy][0].ToString() != "0")
                    {
                        if (U_Id != "")
                        {
                            SingleStore = Store.Tables[0].Rows[0][0].ToString().Split('|');//1,78|2,56|3,78|4,23
                        }
                        else
                        {
                            SingleStore = Store.Tables[0].Rows[yy][0].ToString().Split('|');//1,78|2,56|3,78|4,23
                        }
                        int ss = 0;
                        for (int cc = 0; cc < SingleStore.Length; cc++)
                        {
                            string[] MyScore = SingleStore[cc].Split(',');//1,78
                            ss = int.Parse(MyScore[1].ToString());
                            ds.Tables[0].Rows[yy][2 + cc] = ss.ToString();
                        }
                    }
                }
            }
            return ds;
其中string[] SingleStore = null;是声明一个数组吗?还是什么

解决方案 »

  1.   

    string[] SingleStore 字符串数组,初始为null,不分配空间
    DataSet ds = DBHelp.DateSet(strSql.ToString()); //获取数据集,根据sql
      int count = Store.Tables[0].Rows.Count;//记录数
      if (ds.Tables[0].Rows.Count > 0)
      {
      string[] SingleStore = null;
      for (int yy = 0; yy < count; yy++)//此处开始遍历记录
      {
      if (Store.Tables[0].Rows[yy][0].ToString() != "0")//如果第yy索引行第一个列的值不等0
      {
      if (U_Id != "")
      {
      SingleStore = Store.Tables[0].Rows[0][0].ToString().Split('|');//1,78|2,56|3,78|4,23//字符串分割,以'|'为分隔符,将单元格内容分割为数组
      }
      else
      {
      SingleStore = Store.Tables[0].Rows[yy][0].ToString().Split('|');//1,78|2,56|3,78|4,23//同上
      }
      int ss = 0;
      for (int cc = 0; cc < SingleStore.Length; cc++)//根据数组的记录数循环
      {
      string[] MyScore = SingleStore[cc].Split(',');//1,78
      ss = int.Parse(MyScore[1].ToString());//转为int型
      ds.Tables[0].Rows[yy][2 + cc] = ss.ToString();
      }
      }
      }
      }
      return ds;
      

  2.   

    就是 把对应ID的分数更新到datasetstring[] SingleStore = null 声明一个字符串数组,其实也可以用List<string>
      

  3.   

    声明一个字符型数组,赋值为null