regioninfo

.NET RegionInfo class

懵懂的女人 提交于 2019-12-03 07:04:54
When I try to create a new RegionInfo with certain ISO 3166 country codes ("BD" for Bangladesh, "SO" for Somalia, "LK" for Sri Lanka), I get an ArgumentException that says it's not recognized. What's the deal? The Intellisense of RegionInfo(string) says it conforms to ISO 3166, but these country/region codes are not supported? I don't get it. .NET doesn't provide all Cultures/Regions out-of-the-box. Note the 'predefined' RegionInfos here: http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo(VS.80).aspx . Unfortunately, if you want to use non-predefined Regions, you have to

Get country and timestamp for the current location

风格不统一 提交于 2019-12-02 04:41:20
问题 I want to know where my application is used. Here is the code for getting the country name: public string Country = RegionInfo.CurrentRegion.DisplayName; Here is the code to get the timezone: public void TimeStamp() { TimeZone zone = TimeZone.CurrentTimeZone; // Demonstrate ToLocalTime and ToUniversalTime. DateTime local = zone.ToLocalTime(DateTime.Now); _TimeStamp = local.ToString(); } I want to see if this works for other locations and IP addresses. I have tried to change my IP address

Get RegionInfo by country name?

﹥>﹥吖頭↗ 提交于 2019-11-30 22:53:24
问题 I want to be able to get RegionInfo by doing the following: new RegionInfo("United Kingdom"); but this throws an exception and says that it is not recognised. This page on RegionInfo says that an exception is thrown if 'name is not a valid country/region name'. And yet this page specifies a list of predefined regions used by the class that and contains United Kingdom , so why doesn't creating a new RegionInfo with country name work? 回答1: var regions = CultureInfo.GetCultures(CultureTypes

Best Practice - Format Multiple Currencies

我与影子孤独终老i 提交于 2019-11-30 11:33:32
问题 What is best practice for the scenario listed below? We have an application which we would like to support multiple currencies. The software will respect the users locale and regional settings to dictate the correct number format, i.e. $10,000.00 or 10.000,00₴ etc. We would however like to be able to format different numbers based upon a currency ID (perhaps the three letter ISO4217 code). Our idea is to store a table in the database with each currency and then request from the user to select

Best Practice - Format Multiple Currencies

こ雲淡風輕ζ 提交于 2019-11-30 00:21:01
What is best practice for the scenario listed below? We have an application which we would like to support multiple currencies. The software will respect the users locale and regional settings to dictate the correct number format, i.e. $10,000.00 or 10.000,00₴ etc. We would however like to be able to format different numbers based upon a currency ID (perhaps the three letter ISO4217 code). Our idea is to store a table in the database with each currency and then request from the user to select the currency symbol which will be used. The program will then format all numbers based upon the locale