D
Drakemar
Hello all,
Thank you for taking the time to read and help me with my question.
Here is a simplified program I have:
int[,] array2D = { {1, 2, 3}, {4, 5, 6} };
private void Main(){
printarray2DValue(0);
printarray2DValue(1);
}
printarray2DValue(int dValue){
int length;
int i=0;
int x;
int y;
string str;
if (dValue==0){
length = array2D .GetLength(0);
x=i;
y=0;
}
else{
length = array2D .GetLength(1);
x=0;
y=1;
}
for (i;i<length;i++){
str += 2dArray[x,y].ToString();
}
MessageBox.Show(str);
}
Now, that obviously doesn't work how I would want it to. And I can't
say "x= ref i" either because C# won't allow it. I read
http://www.yoda.arachsys.com/csharp/parameters.html, and
http://groups.google.ca/group/micro...lnk=gst&q=reference+variable#18c83a169e66dacb
and I believe my answer is that I can not do what I want, unless I use
unsafe code, or boxing.
The easiest solution is just to split this into two methods, one for
each dimension of the array. But, the more dimensions, the more
methods, and thats not good.
Any suggestions?
Thank you for taking the time to read and help me with my question.
Here is a simplified program I have:
int[,] array2D = { {1, 2, 3}, {4, 5, 6} };
private void Main(){
printarray2DValue(0);
printarray2DValue(1);
}
printarray2DValue(int dValue){
int length;
int i=0;
int x;
int y;
string str;
if (dValue==0){
length = array2D .GetLength(0);
x=i;
y=0;
}
else{
length = array2D .GetLength(1);
x=0;
y=1;
}
for (i;i<length;i++){
str += 2dArray[x,y].ToString();
}
MessageBox.Show(str);
}
Now, that obviously doesn't work how I would want it to. And I can't
say "x= ref i" either because C# won't allow it. I read
http://www.yoda.arachsys.com/csharp/parameters.html, and
http://groups.google.ca/group/micro...lnk=gst&q=reference+variable#18c83a169e66dacb
and I believe my answer is that I can not do what I want, unless I use
unsafe code, or boxing.
The easiest solution is just to split this into two methods, one for
each dimension of the array. But, the more dimensions, the more
methods, and thats not good.
Any suggestions?