Skip to main content
 首页 » 编程设计

c#之应为错误方法名称

2024年02月24日25sky-heaven

private void button1_Click(object sender, EventArgs e) 
 
{ 
 
  int[] ml = new int[10] ( 1, 2, 3, 4, 5, 6, 7, 8, 9 ); 
 
  MessageBox.Show(Convert.ToString(ml.Length), "Length"); 
 
 
} 

我收到这个错误,谁能告诉我我做错了什么

错误 1 ​​方法名称应为 C:\Users\Admin\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 21 24 WindowsFormsApplication1

请您参考如下方法:

int[] ml = new int[10] ( 1, 2, 3, 4, 5, 6, 7, 8, 9 ); 

应该是

int[] ml = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };