将char []数组中的元素转换为double [英] Convert elements in char[] array to double

查看:942
本文介绍了将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));
   }


这篇关于将char []数组中的元素转换为double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆