在C#中浮动到字符串转换 [英] Float to string conversion in C#

查看:64
本文介绍了在C#中浮动到字符串转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的其他人有与我相同的问题,但他的反应是没有解决我的问题,所以我希望有人可以帮助我(对于一些

的理由我无法回复与原版相同的帖子。


我正在尝试将字符串转换为浮点数。它包含一个浮动值

,但是当我尝试:


float myfloat = System.Convert.ToSingle(strfloat);


我得到一个例外说明日期时间类型的东西,我没有

真的理解


帮助??


TIA

Mish

x

解决方案

" mishj" ; < MI *** @ yahoo.com>在消息中写道

新闻:11 ********************** @ g43g2000cwa.googlegr oups.com ...

我得到一个例外,说明我不理解的日期时间类型




有错误你得到了通过实际告诉我们

错误消息是什么来轻松解决。一旦你这样做,这里有人会为你解决你的问题...


mishj,

尝试直接调用float.Parse(它与Single.Parse相同)


你能否发布异常消息+你想要的字符串

兑换?

-

HTH

Stoitcho Goutsev(100)


" mishj" < MI *** @ yahoo.com>在消息中写道

news:11 ********************** @ g43g2000cwa.googlegr oups.com ...

这里的其他人有与我相同的问题,但是他的回答没有解决我的问题,所以我希望有人可以帮助我(因为一些原因我无法回复与原版相同的线程)

我正在尝试将字符串转换为浮点数。它包含一个浮动值
但是当我尝试:

浮动myfloat = System.Convert.Toingle(strfloat);

我得到一个例外,说明日期我不理解的时间类型

帮助??

TIA
Mish
x



您好,mishj!


您可以在此处发布异常文本,如果可能的话,还可以发布strfloat值吗?


-

问候,Vadym Stetsyak

www: http://vadmyst.blogspot.com

Someone else on here had the same issue as I have but the response he
got didnt solve my problem so I hope someone can help me (for some
reason I was unable to reply on the same thread as the original)

I am trying to convert a string to a float. It contains a float value
but when I try:

float myfloat = System.Convert.ToSingle(strfloat);

I get an exception saying something about date time types that I dont
really understand

Help??

TIA
Mish
x

解决方案

"mishj" <mi***@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...

I get an exception saying something about date time types that I dont
really understand



There error you''re getting is easily solved by actually telling us what the
error message is. As soon as you do that, somebody here will solve your
problem for you...


mishj,

Try to call directly float.Parse (it is the same as Single.Parse)

Can you please post the exception message + the string you are trying to
convert?
--
HTH
Stoitcho Goutsev (100)

"mishj" <mi***@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...

Someone else on here had the same issue as I have but the response he
got didnt solve my problem so I hope someone can help me (for some
reason I was unable to reply on the same thread as the original)

I am trying to convert a string to a float. It contains a float value
but when I try:

float myfloat = System.Convert.ToSingle(strfloat);

I get an exception saying something about date time types that I dont
really understand

Help??

TIA
Mish
x



Hello, mishj!

Can you post the exception text here and, if possible, strfloat value?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com


这篇关于在C#中浮动到字符串转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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