需要功能,可自动检测字符串中任何数字后的退邮件点 [英] Need function which automatic detect decmail point after any digits in string
本文介绍了需要功能,可自动检测字符串中任何数字后的退邮件点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何功能可以自动检测字符串中任何数字后的退邮件点.
例子;字符串str = 123456789
我想将此字符串解析为十进制,并且它在5之后自动采用十进制.(如12345.6789)
需要紧急帮助.
在此先感谢您.
Is there any function which automatic detect decmail point after any digits in string.
Example; string str=123456789
I want to parse this string as decimal and it auto takes decimal after 5. (Like 12345.6789)
Need urgent help.
Thanks in advance.
推荐答案
尝试:
string test = "123456789";
if (!test.Contains('.'))
{
test = string.Format("{0}.{1}", test.Substring(0, 5), test.Substring(5));
}
decimal myValue = (Convert.ToDecimal(str)/10000);
这篇关于需要功能,可自动检测字符串中任何数字后的退邮件点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文