浮动到Money演员 [英] float to Money cast
本文介绍了浮动到Money演员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下内容:
float.Parse(myproduct.Price.Value.ToString());
myproduct.Price.Value.ToString()返回$ 24.00(带$)
无论如何都要做上面的演员,我知道float.Parse(... )
不喜欢$,因为我一直得到一个无效的演员异常,无论如何都是为了让这个有效吗?我只需要用子串消除$
,还是有更好的方法来投射它?
谢谢。
Hi,
I have the following:
float.Parse(myproduct.Price.Value.ToString());
myproduct.Price.Value.ToString() returns $24.00 (with the $)
Is there anyway to do the above cast, I know the float.Parse(...)
doesn''t like the $, as i keep getting an invalid cast exception, is
there anyway to get this to work? Do i just need to strip out the $
with substring, or is there a better way to cast it?
Thanks.
推荐答案
24.00(带
)
无论如何做上面的演员,我知道float.Parse(...)
不喜欢
)
Is there anyway to do the above cast, I know the float.Parse(...)
doesn''t like the
,因为我一直得到一个无效的演员例外,
无论如何都可以让它发挥作用?我只需要删除
, as i keep getting an invalid cast exception, is
there anyway to get this to work? Do i just need to strip out the
这篇关于浮动到Money演员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文