-2

I want convert 1,2,3,4,5,6,7,8,9,10 String to Double.

I tried Convert.ToDouble(String); and Double.Parse(String); but returned 1.0

How to convert multi comma string to double?

Thanks for help.

Glenn Ferrie
  • 10,290
  • 3
  • 42
  • 73
user3877422
  • 3,687
  • 3
  • 13
  • 6

1 Answers1

4

From the looks of your question you actually have 10 numbers not 1. Use this code:

var nums = "1,2,3,4,5,6,7,8,9,10";
var digits = nums.Split(',').Select(r => Convert.ToDouble(r)).ToArray();
// the result will be an array of doubles, also this only works with .NET 3.5 or better.

Let me know if this works for you.

Glenn Ferrie
  • 10,290
  • 3
  • 42
  • 73