c# - How to create a matrix without a loop -


i know if possible create matrix without writing loop. try start simple list of range don't know how go further.

enumerable.range(1, 4).tolist() 

here code 3 loops :

    private static int[][] calculpossiblecombinaison(){     int l;     (int = 1; < 5; i++) {         (int j = 1; j < 5; j++) {             (int k = 1; k < 5; k++) {                 l = (i*j*k)-1;                 combinaison[l][0] = i;                 combinaison[l][1] = j;                 combinaison[l][2] = k;                 console.writeline("["+combinaison[l][0]+","+combinaison[l][1]+","+combinaison[l][2]+"]");             }         }     }     return combinaison; } 

this result of matrix

[1,1,1] [1,1,2] [1,1,3] [1,2,1] [1,2,2] [1,2,3] [1,3,1] [1,3,2] [1,3,3] [2,1,1] [2,1,2] [2,1,3] [2,2,1] [2,2,2] [2,2,3] [2,3,1] [2,3,2] [2,3,3] [3,1,1] [3,1,2] [3,1,3] [3,2,1] [3,2,2] [3,2,3] [3,3,1] [3,3,2] [3,3,3] 

do think it's possible ?

thx lot

try

enumerable.range(1, 3) .selectmany(x => enumerable.range(1, 3), (x, y) => new[] {x, y})     .selectmany(x => enumerable.range(1, 3), (x, y) => new[] {x[0], x[1], y}).toarray(); 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -