culture

how to handle culture in double parsing in c#?

二次信任 提交于 2019-12-22 11:26:12
问题 I have a question about how to handle culture while parsing doubles. In a system price information from various servers comes together. However the data thats given as input varies in culture. two million and fifty cents is given as : "2.000.000,50" "2,000,000.50" "2000000.50" "2000000,50" is there a generic way to handle these various types of input ? 回答1: No, there is no generic way. You either need to know what culture the double was formatted or all the servers need to send in a single

Problem with Convert.ToDateTime in asp.net

心不动则不痛 提交于 2019-12-21 23:50:17
问题 I have an application that works without any problem in a spanish server. When i uploaded the application into the online server (an english windows), im getting exceptions (of type "input string is not a valid Datetime/Int32") with Convert.ToDateTime and Convert.ToInt32. Are any web.config line that could help me in this matter? I tried adding a globalization element with the Spanish culture, but didnt worked. Could you give me a hand? Thanks in advance. Josema. 回答1: You need: System

.NET How to compare two Strings that represent filenames ignoring case correctly

房东的猫 提交于 2019-12-18 18:49:52
问题 Given that (at least on NTFS) the filesystem on Windows is case insensitive, I would like to compare String fileA to String fileB as such: fileA.Equals(fileB, StringComparison.CurrentCultureIgnoreCase) The question then becomes which culture I should use, does the default current (ui?) culture suffice? I can't seem to find any BCL methods for this purpose. 回答1: You should use StringComparison.OrdinalIgnoreCase , according to Best Practices for Using Strings in the .NET Framework. The string

is StringComparison.Ordinal the same as InvariantCulture for testing equality?

主宰稳场 提交于 2019-12-18 12:14:15
问题 From their brief summary descriptions, it sounds like the string comparison rules StringComparison.Ordinal and StringComparison.InvariantCulture are meant to differ in how they do sorting of strings. Is that all ? i.e., does that mean we can use either string comparison rule when doing an equality comparison? string.Equals(a, b, StringComparison....) And for extra credit: does it make a difference to the answer if we compare OrdinalIgnoreCase and InvariantCultureIgnoreCase ? How? Please

Localization: How to map culture info to a script name or Unicode character range?

时间秒杀一切 提交于 2019-12-18 09:12:27
问题 I need some information about localization. I am using .net 2.0 with C# 2.0 which takes care of most of the localization related issues. However, I need to manually draw the alphabets corresponding to the current culture on the screen in one particular screen. This would be similar to the Contacts screen in Microsoft Outlook (Address Cards view or Detailed Address Cards View under Contacts), and so it needs a the column of buttons at the right end, one for each alphabet. I am trying to

.NET Culture change event?

早过忘川 提交于 2019-12-18 05:09:26
问题 I have a .NET custom control that displays information in a culture dependant way. To improve performance I cache some information inside the control rather than generate it every time. I need to know if the culture has changed so that I can regenerate this internal info as appropriate. Is there some event I have hook into? Or do I have to just test the culture setting every time I paint to see if it has changed? 回答1: You can either handle the SystemEvents.UserPreferenceChanged event:

In .Net: best way for keeping CurrentCulture on new Thread?

牧云@^-^@ 提交于 2019-12-18 03:52:09
问题 In a .Net 4.0 WPF project, we need to keep the same CurrentCulture on each thread then we have on the main thread. Given, we can initialize a new thread's culture with code like the following: Keep the information in a variable (context) context.CurrentCulture = Thread.CurrentThread.CurrentCulture; context.CurrentUICulture = Thread.CurrentThread.CurrentUICulture; On the new thread, initialize from the saved context Thread.CurrentThread.CurrentCulture = context.CurrentCulture; Thread

In .Net: best way for keeping CurrentCulture on new Thread?

泪湿孤枕 提交于 2019-12-18 03:51:26
问题 In a .Net 4.0 WPF project, we need to keep the same CurrentCulture on each thread then we have on the main thread. Given, we can initialize a new thread's culture with code like the following: Keep the information in a variable (context) context.CurrentCulture = Thread.CurrentThread.CurrentCulture; context.CurrentUICulture = Thread.CurrentThread.CurrentUICulture; On the new thread, initialize from the saved context Thread.CurrentThread.CurrentCulture = context.CurrentCulture; Thread

Output cache for multi-tenant application, varying by hostname and culture

我怕爱的太早我们不能终老 提交于 2019-12-17 21:52:19
问题 I have a multi-tenant application in ASP.NET MVC. The instance of the application that will be served is function of the hostname alone (something along the lines of stackexchange, I suppose). Each instance of the application might have a different culture setting (even "auto", to read the browser's language and try to use it), and will be localized accordingly. In this situation, I'd like to do some output caching on some of my actions. So, my questions are: What are the possibilities to

How to change culture to a DateTimepicker or calendar control in .Net

…衆ロ難τιáo~ 提交于 2019-12-17 15:58:08
问题 How to set internationalization to a DateTimepicker or Calendar WinForm control in .Net when the desire culture is different to the one installed in the PC? 回答1: It doesn't seem to be possible to change the culture. See this KB article. 回答2: Based on previous solution, I think the better is: dateTimePicker.Format = DateTimePickerFormat.Custom; dateTimePicker.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern; 回答3: System.Threading.Thread.CurrentThread.CurrentCulture =