将char []数组中的元素转换为double
问题描述:
I have the following char array:
char[] number = {'4', '3', '12', '5'};
如何将char数组中的每个元素都转换为double?
How do I convert each element in the char array to a double?
答
忽略了无法编译的内容(文字中的字符过多-'12' '不是字符)应该可以正常工作:
Ignoring that that won''t compile (too many characters in literal - ''12'' is not a character) this should work:
foreach (char c in number)
{
double d = Convert.ToDouble(new string(c, 1));
}