Hello All,
I have a string which contains "100,200,300,400" and I am unable to convert this to a double[]. I have tried a few ideas although nothing seems to work.
Any ideas?
thanks!
Hello All,
I have a string which contains "100,200,300,400" and I am unable to convert this to a double[]. I have tried a few ideas although nothing seems to work.
Any ideas?
thanks!
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
DavePosted Jun 4, 2008, 10:53 PM
String numbers = "100,200,300,400";
String[] numberInStringArray = numbers.Split(',');
double[] arrayOfDouble = new double[numberInStringArray.Length];
for (int i = 0; i < numberInStringArray.Length; i++)
arrayOfDouble[i] = Convert.ToDouble(numberInStringArray[i]);
// view our efforts:
for (int i = 0; i < numberInStringArray.Length; i++)
Console.Write(arrayOfDouble[i] + " ");