2011-09-20 35 views

回答

2

在您的資源中存儲不同國家的數字格式,然後根據CultureInfo.Current使用它。在這種情況下,你需要你的phne數字資源存儲像Fastest way to format a phone number in C#?

string currentCulturePhoneFormat = Resources.ResourceManager.GetString("phone-format-" + System.Globalization.CultureInfo.CurrentCulture.Name); 

lblPhone.Text = String.Format(currentCulturePhoneFormat, myEntity.PhoneNumber); 

如何申請電話號碼的格式,你可以在這裏閱讀

phone-format-en-US // for USA 
phone-format-de-DE // for Germany 
phone-format-fr-FR // for France 

或者,如果你正在使用的本地化,只需將phone-number-format置於每種文化的資源文件中即可。

+0

@ Samich:嗨Thanx爲您寶貴的答覆,這是偉大的,但你能告訴我我是否應該存儲每個國家的電話號碼格式在每個.resx文件。其他替代品是否...?回覆Plz ... – Swapnil

+0

如果每個文化都有多個.resx文件 - 是的,請將每個.resx:us電話號碼放在resource-us.resx中,等等。在代碼中,只需使用Resources.PhoneNumber '和電話號碼格式將根據選定的文化進行更改。 – Samich

+0

@ Samich:非常感謝你的朋友... – Swapnil

相關問題