0

我想在 C# 中指定一个自定义千位分隔符,并且我希望它与文化无关。

我想要的格式字符串是:XXX.XXX,XX

例如 1.134,43

任何人都可以给我一些建议吗?

谢谢,帕诺斯。

4

1 回答 1

0

我会使用正则表达式来检查您的号码的格式,如下所示:

    // 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)
    {
        // ...
    }
于 2013-05-09T08:56:07.107 回答