我如何初始化INT [] []? [英] How do i initialize int[][]?
本文介绍了我如何初始化INT [] []?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C#中我如何初始化
int[][] test;
我不希望使用 INT [,]
来代替。我问具体怎么初始化以上。最明显的 = INT [1] [1]
不起作用。我试过,没有运气了几个不同的方式和[] []是不是真的谷歌能够很遗憾(除非其可能!?)
I don't want to use int[,]
instead. I am asking specifically how to initialize the above. The obvious = int[1][1]
does not work. I tried a few different ways with no luck and [][] is not really google-able unfortunately (unless its possible!?)
推荐答案
这就是所谓的交错数组的,如果你想google一下。
It's called jagged arrays if you want to Google it.
基本上你可以用传统的方式初始化第一维:
Basically you can initialize the first dimension in the traditional way :
int[][] test = new int[23][];
和手动初始化其他:
for (int i = 0; i < test.Length; ++i)
test[i] = new int[42];
这篇关于我如何初始化INT [] []?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文