0

I have a String array.. myArr[3,7,x].. The array holds user input and before passing to my stored proc I would like to convert the values in the 3rd dimension to csv.. For eg if x=2 and [3,7,0]=1 and [3,7,1]=2 and [3,7,2]=3 then the csv would be 1,2,3.

I thought there would be an easy way to do this using String.Join(",",myArr[3,7].something..)

Not sure if this is possible or whats the way to do it. The other option I tried was generic list (http://stackoverflow.com/questions/1890093/converting-a-generic-list-to-a-csv-string) but that requires Linq(?) and we are on .Net2.

Any ideas? Can write my own custom function to do this but just wondering if there is anything within the framework that allows me to do this. Any help is appreciated.

cheers

Park
  • 3
  • 1

1 Answers1

0

No, there is no built in way to get a cross section of an array that way. Simply create an array and copy the values in a loop:

string[] values = new string[3];
for (int i = 0; i < 3; i++) {
  values[i] = myArr[3, 7, i];
}
string csv = String.Join(", ", values);
Guffa
  • 687,336
  • 108
  • 737
  • 1,005