Hi I am using a 2dimensional array:
I need to send every row of this array through a function with definition:Code:double[,] matrix = new double[countX, countY];
If I used a jagged [][] array instead of the [,] array this would be easy:Code:void ProcessRowOfMatrix(double[] row){ ... }
With a [,] array I could do it like:Code:double[][] matrix = new double[countX][countY]; for(int i=0; i<countX; i++){ ProcessRowOfMatrix(matrix[i]); }
But that's not very elegant... In languages like mathlab rows or colums of 2dimensional arrays can be accesed like:Code:double[,] matrix = new double[countX,countY]; for(int i=0; i<countX; i++){ double[] tmpdblarr = new double[countY]; for(int j=0; j<countY; j++){ tmpdblarr[j] = matrix[i,j] } ProcessRowOfMatrix(tmpdblarr); }
This is very elegant! But it does not work in C# though.Code:double[,] matrix = new double[countX, countY]; for(int i; i<countX;i++){ ProcessRowOfMatrix(matrix[i,:]); }
I was wondering maybe there is just another syntax to achieve this also in C#? And maybe somebody can tell me what it is...
Thank you in advance
BramGo




Reply With Quote