cultureinfo

Culture invariant Decimal.TryParse()

£可爱£侵袭症+ 提交于 2019-11-28 08:04:43
I'm writing a custom string to decimal validator that needs to use Decimal.TryParse that ignores culture (i.e. doesn't care if the input contains "." or "," as decimal point separator). This is the suggested method: public static bool TryParse( string s, NumberStyles style, IFormatProvider provider, out decimal result ) I can't figure out what to use as the 3rd parameter. The examples I've seen look like this: culture = CultureInfo.CreateSpecificCulture("en-GB"); Decimal.TryParse(value, style, culture, out number) so they create a specific culture. CultureInfo does not have a

Get the currency from current culture?

纵然是瞬间 提交于 2019-11-28 07:08:18
Is there a way to get current information dynamically from the apps culture settings? Basically if the user has set the culture to US I want to know the currency is dollars, or if they have it set to UK I want to pound sterling etc... etc.. This is so I can send this information to PayPal when a payment is being made Use the RegionInfo.ISOCurrencySymbol property. For example: var ri = new RegionInfo(System.Threading.Thread.CurrentThread.CurrentUICulture.LCID); Console.WriteLine(ri.ISOCurrencySymbol); Output: "USD" You can get the symbol from CultureInfo.CurrentCulture.NumberFormat

Why not all countries are presented in CultureInfo.GetCultures()?

白昼怎懂夜的黑 提交于 2019-11-28 07:04:26
问题 I am using this standard code for populating list of countries: static void Main(string[] args) { List cultureList = new List(); CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures); foreach (CultureInfo culture in cultures) { try { RegionInfo region = new RegionInfo(culture.LCID); if (!(cultureList.Contains(region.EnglishName))) { cultureList.Add(region.EnglishName); Console.WriteLine(region.EnglishName); } } catch (ArgumentException ex)

how to set default culture info for entire c# application

冷暖自知 提交于 2019-11-28 05:40:33
I want to set default culture info for that class or for entire application. For example in Turkey 3,2 = in english 3.2 so application uses my local but i want it to use as default System.Globalization.CultureInfo.InvariantCulture How can i set it to that as default for that specific class or for entire application Alexei Levenkov Not for entire application or particular class. CurrentUICulture and CurrentCulture are settable per thread as discussed here Is there a way of setting culture for a whole application? All current threads and new threads? . You can't change InvariantCulture at all.

How to set Silverlight CurrentUICulture/CurrentCulture correctly?

别等时光非礼了梦想. 提交于 2019-11-28 04:03:44
问题 I'm working on a SL5 app with C# and I'm looking to internationalize it. I found the following to set the UI culture: var culture = new CultureInfo(Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName); Thread.CurrentThread.CurrentUICulture = culture; Thread.CurrentThread.CurrentCulture = culture; Some controls like the DatePicker seem to pick this up. If I format any datetime by using the 'd' format string, I still get the default format "M/dd/yyyy" however. Exactly how does SL

Finding weekend days based on culture

[亡魂溺海] 提交于 2019-11-28 03:11:31
问题 Is there a way to find the days that constitute a weekend or workweek based on different cultures using the .NET framework? For example, some Muslim countries have a workweek from Sunday through Thursday. 回答1: The only thing i know is how to get the day the week starts. Perhaps this can help: CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek from System.Globalization , perhaps you find in this package something. There are several Calendar-Classses like JulianCalendar, HebrewCalendar

Why do I get, “Culture is not supported” and What, if Anything, Should I Do about it?

别等时光非礼了梦想. 提交于 2019-11-28 02:51:57
问题 I have a breakpoint on the "return" line here: [HttpGet] [Route("api/Test/{id1}/{id2}")] public NRBQEntity GetTestMessage(String id1, String id2) { return NRBQClient.GetTestMessage(id1, id2); } Although it does not crash the app, when I reach that point, I get, " Exception:Thrown: "Culture is not supported." (System.Globalization.CultureNotFoundException) A System.Globalization.CultureNotFoundException was thrown: "Culture is not supported." " Which culture is trying to be supported, why is

How to enumerate the LOCALIZED alphabet in C#?

人盡茶涼 提交于 2019-11-28 01:52:52
First of all, this is not a duplicate of: Quickest way to enumerate the alphabet Because I need to get all the characters of the alphabet OF AN ARBITRARY (variable) LANGUAGE, and that in the correct ordering sequence. How can I do that without knowing the alphabet of every possible culture/language ? System.Gobalization.Cultureinfo for example has information on date format, and a sorting method, and codepage info. But not info on the alphabet itselfs. Forthermore 'A' to 'Z' ordering iterating won't do, because German for example has characters such as ÄÖÜ, which are after 'Z' in the codepage

Regular expression to match German number

只谈情不闲聊 提交于 2019-11-28 01:36:30
I am wondering, how would regular expression for testing correct format of number for German culture would look like. In German, comma is used as decimal mark and dot is used to separate thousands. Therefore: 1.000 equals to 1000 1,000 equals to 1 1.000,89 equals to 1000.89 1.000.123.456,89 equals to 1000123456.89 The real trick, seems to me, is to make sure, that there could be several dots, optionally followed by comma separator This is the regex I would use: ^-?\d{1,3}(?:\.\d{3})*(?:,\d+)?$ Debuggex Demo And this is a code example to interpret it as a valid floating point (notice the

Formatting numbers in different cultures

自古美人都是妖i 提交于 2019-11-28 01:29:47
问题 Assuming an invariant culture , is it possible to define a different group separator in the format - than the comma? Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Console.WriteLine(String.Format("{0:#,##0}", 2295)); Output: 2,295 Desired output: 2.295 The invariant culture is a requirement because currencies from many different locales are being formatted with format strings, that have been user defined. Ie for Denmark they have defined the price format to be "{0:0},-",