2
Reply

Passing MultiDimensional Arrays to a method in C#

yamid

yamid

Nov 11 2009 10:55 AM
3.2k
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)