开发者

Initialize int[][,] in C#

开发者 https://www.devze.com 2022-12-08 14:52 出处:网络
How I do Initialize this: public co开发者_JAVA百科nst int[][,] Map = ... I would like to do something like this:

How I do Initialize this:

public co开发者_JAVA百科nst int[][,] Map = ...

I would like to do something like this:

public const int[][,] Map = {
    { // Map 1
        {1, 1, 1, 1},
        {1, 1, 1, 1},
        {1, 1, 1, 1},
        {1, 1, 1, 1},
    },
    { // Map 2
        {1, 1, 1, 1},
        {1, 0, 0, 1},
        {1, 0, 0, 1},
        {1, 1, 1, 1},
    },
    // etc.
};

I don't want to create an int[,,] Map, because somewhere else I want to do:

loader.Load(Map[map_numer]); // Load method recieve an int[,]


int[][,] a = new int[][,]
{
    new int[,]
    {
        {1, 1, 1, 1},
        {1, 1, 1, 1},
        {1, 1, 1, 1},
        {1, 1, 1, 1},

    },
    new int[,]
    {
        {1, 1, 1, 1},
        {1, 0, 0, 1},
        {1, 0, 0, 1},
        {1, 1, 1, 1},
    }
};
0

精彩评论

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

关注公众号