yamid

yamid

  • NA
  • 98
  • 0

Passing MultiDimensional Arrays to a method in C#

Nov 11 2009 10:55 AM
I have several arrays in my Program with diffrent diemensions. for example A, B,C,D,E,...( 5-Dim,4-Dim, ...).
I want to write ONE general method that is able to accept all of those arrays with different Ranks inwhich the USER just specifies the rank and program should read this rank and accept it as an argument.
Here I *donot* want to write several methods of the same structure inwhich just the dimensions of input array is changing. instead I will tell the method the dimension of the input array.

for example;



// definition of Array "A","B",..."N" as multi-D arrays of diffrent ranks
....


// Method Victory that Accept an Array of any type but the user should define what is the Rank of the array to be passed

// User Defines this ValueOfRank
int ValueOfRankA =3
....= Victory(A);

int ValueOfRankB =6
....=Victory(B);
...
int ValueOfRankN =3
...=Victory(N)

Answers (2)