开发者

error Method name expected

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");


}

I get this error can someone tell me what I am doing wrong

Error 1 Method name expected 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 );

Should be

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


In C# array values are surrounded by { and } and not parens. Switch to using them in the array declaration and the error will go away.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜