标题:求指点,锯齿数组初始化
取消只看楼主
LeslieChao
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2013-12-6
 问题点数:0 回复次数:1 
求指点,锯齿数组初始化
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”
求大神指点
搜索更多相关主题的帖子: public color 
2013-12-25 15:37
LeslieChao
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2013-12-6
得分:0 
这个是放在新建的class里的,想要在Main里面调用,所以这一页没有写 Main方法
2013-12-25 15:41



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-425678-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053151 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved