Click here to Skip to main content
14,883,822 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
CSS
I have the following char array:
char[] number = {'4', '3', '12', '5'};


How do I convert each element in the char array to a double?
Posted
Comments
shakil0304003 21-Sep-11 2:58am
   
char[] number = {'4', '3', '12', '5'}; is invalid!!!

1 solution

Ignoring that that won't compile (too many characters in literal - '12' is not a character) this should work:
C#
foreach (char c in number)
   {
   double d = Convert.ToDouble(new string(c, 1));
   }
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900