문제

I want to create a 2D jagged array (as previous so answers claims is faster on dot net than multidimensional one).

I want to do something like

Int [][] myarr = new int [2][3]; 

But C# doesn't seem to support this so I did use a for loop for the 2nd dimension instantiation. Yet if I want to fastly reset I cant use memset equivalent as each new in the loop initiate the array in a possible different and not continouse place.

Is there a faster way to init and reset a fixed width jagged array ?

도움이 되었습니까?

해결책

You can use LINQ and Enumerable.Range method, but internally there is still a loop performed:

int[][] myarr = Enumerable.Range(0, 2).Select(x => new int[3]).ToArray();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top