毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 嵌入式 >> 正文

string转换成float的时候出现FormatException

更新时间:2012-12-17:  来源:毕业论文

string转换成float的时候出现FormatException
wince平台在俄文系统上面用C#开发应用程序
将string转换成float的时候出现FormatException,有人遇到过吗

 string a = "3.142";
 float x = Convert.ToSingle(a);

C#没用过。。

可不可以用C标准?

char * str = "3.142";

double x = strtod(str,NULL);

string[] values= { "-1,035.77219", "1AFF", "1e-35",                     "1,635,592,999,999,999,999,999,999", "-17.455",                     "190.34001", "1.29e325"}; float result;   foreach (string value in values) {    try {       result = Convert.ToSingle(value);       Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",                          value.GetType().Name, value,                          result.GetType().Name, result);    }       catch (FormatException) {       Console.WriteLine("Unable to convert '{0}' to a Single.", value);    }                   catch (OverflowException) {       Console.WriteLine("'{0}' is outside the range of a Single.", value);    } }        // The example displays the following output: //    Converted the String value '-1,035.77219' to the Single value -1035.772. //    Unable to convert '1AFF' to a Single. //    Converted the String value '1e-35' to the Single value 1E-35. //    Converted the String value '1,635,592,999,999,999,999,999,999' to the Single value 1.635593E+24. //    Converted the String value '-17.455' to the Single value -17.455. //    Converted the String value '190.34001' to the Single value 190.34. //    '1.29e325' is outside the range of a Single.

 俄文的“.”号用的是“,”

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。