2013-05-09 31 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) 
    { 
     // ... 
    }