2013-05-09 30 views
0

我想在C#中指定一个自定义千位分隔符,并且我希望它独立于文化。指定自定义千位分隔符是独立于文化的

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

e.g 1.134,43

任何人都可以建议我什么事?

谢谢, 帕诺斯。

+0

什么* *正是你说的意思是:“我希望它是独立的文化”?这是一种文化背景 - 听起来你可能想创建自己的CultureInfo,或者找到一个已经有正确数字格式的文件。 – 2013-05-09 08:52:14

+0

您好删除标题中的标记,请参阅:http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles – MUG4N 2013-05-09 08:58:03

+0

@约翰,是的,我想你是对的。我的意思是我不希望格式根据文化而改变。那么我需要创建自己的文化吗? – user2214824 2013-05-09 09:26:09

回答

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) 
    { 
     // ... 
    }