大家看下这段代码:

 

 

代码
 1  private void button1_Click(object sender, EventArgs e)
 2         {
 3             int[] issa = new int[3] { 1234 };       //直接报错
 4             int[] issb = new int[2];
 5             for (int i = 0; i < 5; i++)      //编译报错 越界
 6             {
 7                 issb[i] = i;
 8             }
 9             string[] sssc = new string[3] { "a","b","c"};
10             string[] sssd = new string[0];
11             textBox2.Text = sssd.Length.ToString();      //长度自动变为0
12             string xx = "a;sa;sfe;wef;ewtwe;wetwe;wetwegdf;fdh;y45;rt4;yrt;reyrey;rgterg;rg;";
13            
14             sssd = xx.Split(';');               //一切正常  ??
15             textBox3.Text = sssd.Length.ToString();         //长度自动变为15
16             string[] ssse = new string[20];
17 
18             sssd.CopyTo(ssse, 0);
19 
20             foreach (string str in ssse)
21             {
22                 textBox1.Text = textBox1.Text + " | " + str;
23             }
24         }

 

 

字符串数组sssd居然可以如上使用而不出错,不知为何?

 

相关文章:

  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-15
  • 2021-05-08
  • 2022-12-23
  • 2022-02-19
  • 2021-11-17
相关资源
相似解决方案