Initialize a Jagged Array the LINQ Way

后端 未结 6 2213
孤城傲影
孤城傲影 2020-12-14 04:07

I have a 2-dimensional jagged array (though it\'s always rectangular), which I initialize using the traditional loop:

var myArr = new double[rowCount][];
for         


        
6条回答
  •  甜味超标
    2020-12-14 04:38

    I just wrote this function...

        public static T[][] GetMatrix(int m, int n)
        {
            var v = new T[m][];
            for(int i=0;i

    Seems to work.

    Usage:

    float[][] vertices = GetMatrix(8, 3);
    

提交回复
热议问题