从文本中删除数 [英] Remove number from a textbox

查看:94
本文介绍了从文本中删除数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文本框这个数字84,8441546842904如何在84,8或84,84转换按钮单击事件?

I have this number in textbox "84,8441546842904" how to convert in 84,8 or 84,84 on button click event?

推荐答案

如果通过这个,你的意思是你要分析到一定的小数位数的值,而圆的:

If by this you mean you want to parse the value and round it to a certain number of decimal places:

double value = Math.Round(double.Parse(textbox.Text), 2);



将分析文本和圆形它为2位小数。您可能需要解析考虑到当地文化的数字格式时使用System.Globalization.CultureInfo对象

will parse the text and round it to 2 decimal places. You may need to use a System.Globalization.CultureInfo object when parsing to account for your local culture's number formatting.

请参阅 http://msdn.microsoft.com/en-us/library/75ks3aby.aspx

这篇关于从文本中删除数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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