I'm using vb.net 2008 edition and i was wondering if there a way to convert an array type to another array type. For instance say i dim an array as string and then want to convert the array to the integer data type for sorting, how would i go about this?
+1
A:
You can call Array.ConvertAll
:
intArray = Array.ConvertAll(stringArray, Function(s) Int32.Parse(s))
SLaks
2010-04-26 00:19:12
what is intArray? should i dim a new array called intArray?
Bigfatty
2010-04-26 00:28:03
If you want to. What did you want to do with the array of integers?
SLaks
2010-04-26 00:31:48
well actually i started out with a string array and want to convert it to a integer array. and even though i put that exact line of code in my program it did nothing and stayed a string array. heres what i tried Array.ConvertAll(cardNumber, Function(s) Int32.Parse(s))where cardNumber is just a 5 spot string array.
Bigfatty
2010-04-26 00:39:55
You need to declare a new variable of type `Int32()` and assign the return value to it.
SLaks
2010-04-26 00:41:52
thank for clearing that up! works like a charm :) i'm very grateful . . .
Bigfatty
2010-04-26 00:52:28