我只想在c#中获得List的2维数组.在我的想法中,下面应该有效,但它没有,List的1维数组有效.我将Unity3D与Mono一起使用,但我认为这是与语言相关的问题.
List<MyType>[,] twoDArrayofList;//don't work, it's type is List<MyType>
List<MyType>[] oneDArrayofList;//it's works, the type is List<MyType>
Run Code Online (Sandbox Code Playgroud)
谁知道什么是错的?谢谢.
你是什么意思"不工作"?你遇到了什么错误?
我不知道Mono(或Unity3D),但我只是在.NET项目中尝试了以下内容并得到了我期望的结果:
List<string>[,] strings = new List<string>[2, 2];
strings[0, 0] = new List<string> { "One" };
strings[0, 1] = new List<string> { "Two" };
strings[1, 0] = new List<string> { "Three" };
strings[1, 1] = new List<string> { "Four" };
Run Code Online (Sandbox Code Playgroud)