我想在 C# 中指定一个自定义千位分隔符,并且我希望它与文化无关。
我想要的格式字符串是:XXX.XXX,XX
例如 1.134,43
任何人都可以给我一些建议吗?
谢谢,帕诺斯。
我想在 C# 中指定一个自定义千位分隔符,并且我希望它与文化无关。
我想要的格式字符串是:XXX.XXX,XX
例如 1.134,43
任何人都可以给我一些建议吗?
谢谢,帕诺斯。
我会使用正则表达式来检查您的号码的格式,如下所示:
// First we see the input string.
string input = yourInputNumber.ToString();
// Here we call Regex.Match.
Match match = Regex.Match(input, @"^\d{0,5}(\d\.\d?|\.\d)?\d?$",
RegexOptions.IgnoreCase);
// Here we check the Match instance.
if (match.Success)
{
// ...
}