求指点,锯齿数组初始化
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ShuZu
{
public class JuChiShuZu
{
// int[][] Juchi = new int[3][];
// Juchi[0] = new int[3]{3,4,2};
// Juchi[1] = new int[7]{1,2,3,4,5,6,7};
// Juchi[3] = new int[4]{4,5,6,7};
int[][] Juchi = new int[3][]{
{1,2,3},
{4,5,6,7,8,9},
{1,2,3,4}
};
public void Print()
{
for (int i = 0; i < Juchi.Length; i++)
{
for (int j = 0; j < Juchi[i].Length; j++)
{
Console.Write(Juchi[i][j] + " ");
}
Console.Write('\n');
}
}
}
}
练习锯齿数组初始化,但是总是编译不过,同样的代码,放在notepad++里面可以过的了,但是控制台总是提示
“arry initializers can only be used in a variable or field initializer”
求大神指点