TextBox浮动? string to float decimal ... [英] TextBox to float? string to float decimal...

查看:69
本文介绍了TextBox浮动? string to float decimal ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将值从textBox转换为float,



我试过



floar number = float.Parse(textBox.text);



如果文本框中包含。则不起作用。 (这样做的整个想法)

I want to convert values from a textBox to float,

I tried

floar number = float.Parse(textBox.text);

dont works if the textbox contain "." (the whole idea of doing this)

推荐答案

参见 https://msdn.microsoft.com/en-us/library/2thct5cb(v = vs.110).aspx [ ^ ]。更好的方法是使用<$ href =https://msdn.microsoft.com/en-us/library/26sxas5t(v=)中显示的 TryParse 方法vs.110).aspx> https://msdn.microsoft.com/en-us/library/26sxas5t(v = vs.110).aspx [ ^ ]。
See https://msdn.microsoft.com/en-us/library/2thct5cb(v=vs.110).aspx[^]. A better way is to use the TryParse method as shown at https://msdn.microsoft.com/en-us/library/26sxas5t(v=vs.110).aspx[^].


这篇关于TextBox浮动? string to float decimal ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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