Fast way to convert string array to double array...
-
Hi, What is the fastest way to convert string array to double array? Currently, I am doing this:
double[] arrDouble = new double[arrString.Length]; for(int i=0; i<arrString.Length; i++) { arrDouble[i] = double.Parse(arrString[i]); }
Unfortunately, this is quite slow for big array (about 3 millions). I am looking for a way to improve it. There is a link talking about converting object to double. http://blogs.msdn.com/bclteam/archive/2005/02/11/371436.aspx[^]. You will see that double.Parse is really slow because the object need to be converted to string before pass it to double.Parse. However, it is not the case here. My array is already a string array. I did test using Convert.ToDouble and it doesn't improve the speed. Any idea? Thanks for any help. Cheers :)
-
Hi, What is the fastest way to convert string array to double array? Currently, I am doing this:
double[] arrDouble = new double[arrString.Length]; for(int i=0; i<arrString.Length; i++) { arrDouble[i] = double.Parse(arrString[i]); }
Unfortunately, this is quite slow for big array (about 3 millions). I am looking for a way to improve it. There is a link talking about converting object to double. http://blogs.msdn.com/bclteam/archive/2005/02/11/371436.aspx[^]. You will see that double.Parse is really slow because the object need to be converted to string before pass it to double.Parse. However, it is not the case here. My array is already a string array. I did test using Convert.ToDouble and it doesn't improve the speed. Any idea? Thanks for any help. Cheers :)
-
This will always be a O(n) operation, you can't get it any faster than this. Are you sure you need 3 million items at the same time? regards
-
Yeah, unfortunately :( Thanks though for your help. At least I know there is nothing I can do about it. Cheers :)
Just for curiosity. How long does it take to convert those 3 million items?
-
Just for curiosity. How long does it take to convert those 3 million items?
12 years later and we still haven't heard back. I can see why they wanted to speed this up.