Carl

Carl

  • NA
  • 11
  • 0

Passing subarrays as parameter

Jun 11 2007 7:43 AM
Dear community,

How do I pass a subarray from a multidimensional array as a parameter to a function?

In c the code would be like:
int array[5][5];
array[3][1]= 3;
dosomething(array[3]); // passes the 4th subarray to the function

Declared as:
void dosomething(int[]);

How will the port to c# look like?

int[][] array= new array[5][5]; // syntax error
int[][] array= new array[5,5]; // compile error: cannot cast [,] implicitely to [][]
int[,] array= new array[5,5];
array[3][1]= 3;
dosomething(array[3]); // compile error, 2 dimensions expected

Can someone help me out?

Thanks,
Carl 

Answers (2)