string s = "¥32.00元"; string tmp=""; bool begin = false,noDot = true; foreach(char c in s) { if (char.IsDigit(c) || c=='.' && noDot) { begin = true; tmp+=c; if (c=='.')noDot = false; } else { if (begin)break; } } decimal val = decimal.Parse(tmp);//你要的数值
cancerser(都是混饭吃,记得要结帖)方法OK试了一下,不错加个using System.Text.RegularExpressions;命名空间后面再Double d = System.Convert.ToDouble(a);转一下收藏他的
string a=reg.Match("CNY20元").Value;
//这样应该可以
string tmp="";
bool begin = false,noDot = true;
foreach(char c in s)
{
if (char.IsDigit(c) || c=='.' && noDot)
{
begin = true;
tmp+=c;
if (c=='.')noDot = false;
}
else
{
if (begin)break;
}
}
decimal val = decimal.Parse(tmp);//你要的数值