我想要一个在指定单词/数字后删除的代码 [英] i want a code that deletes after specified word/number

查看:94
本文介绍了我想要一个在指定单词/数字后删除的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个在指定单词/数字后删除的代码,例如...

如果文本框包含("123 .4 "),我想使用代码删除"."之后的每个单词/数字.

i want a code that deletes after specified word/number like...

if textbox contains ("123.4") i want to delete every word/number after "." with a code.

推荐答案

这很简单.您可以自己使用IndexOf和Replace或Loop的组合,并将仅有效字符复制到新字符串中.你卡在哪一部分?


您可以尝试:
This is very simple. You can use a combination of IndexOf and Replace or Loop through it yourself and copy only the valid characters to a new string. What part are you stuck on?


You can try:
string x = "123.4".Split(''.'')[0];



您确定不想舍入吗?如果是这样,请尝试转换为数字并使用Math.Round,然后转换回字符串.



Are you sure you don''t want to round though? If so, try converting to number and using Math.Round, then convert back to string.


这篇关于我想要一个在指定单词/数字后删除的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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