none
能帮我看看这个程序为什么 索引超出数组界限吗? RRS feed

  • 问题

  •  string[] dh = new string[1000];
                string[] cc = new string[1000];
                string[] kg = new string[1000];
                string[] cc2 = new string[1000];
                string[] s0606 = new string[1000];
                s0606 = File.ReadAllLines("D:\\file\\0606text.txt");
               // Console.WriteLine(s0606[0]);
               /* foreach (string s in s0606)
                {
                    Console.WriteLine(s);
                }
        
                Console.WriteLine("\n文件读取结束!下面进行修改!");*/
                char[] separator1 ={' '};
                char[] separator2 ={','};
     
              
                for (int i = 12; i < 150; i++)
                {
                   
                    kg = s0606[i].Split(separator1);
                    int m = 0; int a = 0; int b = 0;
                    for (int n=0 ; n < 2;)
                    {
                        cc[m] = kg[n];
                        if (m > 0&&m%2!=0)
                        {
                            dh = cc[m].Split(separator2);
                            for (b = 0; b < 2; )
                            {
                                cc2[a] = dh[b];
                                b++;
                            }
                            a++;
                        }
                       
                         m++;  n++;
                    }

                }
                for(int h=0;h<70; h+=5)
                {
                    Console.WriteLine("{0},,{1},{2},{3}",cc2[h],cc2[h+3],cc2[h+2],cc2[h+4]);
                 }
               

    另外我想将最后显示的内容修改到原文件中,应该用什么函数?

    小弟菜鸟,请各位大虾多多指教。谢谢~

    2011年6月8日 15:14

答案

全部回复