int[, ,] array3 = new int[ , , ] { { { 1, 2, 3 }}, { { 4, 5...

发布网友 发布时间:2024-10-24 01:22

我来回答

3个回答

热心网友 时间:2024-11-20 20:57

int[, ,] array3 = new int[,,] { { { 1, 2, 3 } }, { { 4, 5, 6 } } };
Console.WriteLine(array3.Rank);
用的好好的
C#允许这样的初始化方式
或者你直接一个等号等过去
int[, ,] array3 = { { { 1, 2, 3 } }, { { 4, 5, 6 } } };
又或者
int[, ,] array3 = new int[2, 1, 3];
然后赋值

热心网友 时间:2024-11-20 21:01

给你看看英文原版,有例子和说明的
You can initialize an array of a primitive type to something besides 0 using this syntax:
int[] intArray = { 0, 3, 6, 9, 12, 15, 18, 21, 24, 27 };
Perhaps surprisingly, this single statement takes the place of both the reference
declaration and the use of new to create the array. The numbers within the curly braces
are called the initialization list. The size of the array is determined by the number of
values in this list.

热心网友 时间:2024-11-20 20:58

int[, ,] array3 = new int[ , , ] { { { 1, 2, 3 }}, { { 4, 5, 6 } } };
这是错误形式

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com