cultureinfo

Why can't DateTime.ParseExact() parse “9/1/2009” using “M/d/yyyy”

人走茶凉 提交于 2019-11-26 04:25:57
问题 I have a string that looks like this: \"9/1/2009\". I want to convert it to a DateTime object (using C#). This works: DateTime.Parse(\"9/1/2009\", new CultureInfo(\"en-US\")); But I don\'t understand why this doesn\'t work: DateTime.ParseExact(\"9/1/2009\", \"M/d/yyyy\", null); There\'s no word in the date (like \"September\"), and I know the specific format, so I\'d rather use ParseExact (and I don\'t see why CultureInfo would be needed). But I keep getting the dreaded \"String was not

What is the difference between CurrentCulture and CurrentUICulture properties of CultureInfo in .NET?

☆樱花仙子☆ 提交于 2019-11-26 01:46:34
问题 In .NET there is the CultureInfo class in the System.Globalization namespace. It has two similar properties both returning values of the CultureInfo type: CurrentCulture and CurrentUICulture . What is the difference between them? Which one should I use when and why? 回答1: CurrentCulture is the .NET representation of the default user locale of the system. This controls default number and date formatting and the like. CurrentUICulture refers to the default user interface language, a setting

Is there a way of setting culture for a whole application? All current threads and new threads?

[亡魂溺海] 提交于 2019-11-26 00:43:02
问题 Is there a way of setting culture for a whole application? All current threads and new threads? We have the name of the culture stored in a database, and when our application starts, we do CultureInfo ci = new CultureInfo(theCultureString); Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci; But, of course, this gets \"lost\" when we want to do something in a new thread. Is there a way of setting that CurrentCulture and CurrentUICulture for the whole

How to use localization in C#

自作多情 提交于 2019-11-25 23:59:26
问题 I just can\'t seem to get localization to work. I have a class library. Now I want to create resx files in there, and return some values based on the thread culture. How can I do that? 回答1: Add a Resource file to your project (you can call it "strings.resx") by doing the following: Right-click Properties in the project, select Add -> New Item... in the context menu, then in the list of Visual C# Items pick "Resources file" and name it strings.resx . Add a string resouce in the resx file and

What is the difference between CurrentCulture and CurrentUICulture properties of CultureInfo in .NET?

狂风中的少年 提交于 2019-11-25 20:18:56
In .NET there is the CultureInfo class in the System.Globalization namespace. It has two similar properties both returning values of the CultureInfo type: CurrentCulture and CurrentUICulture . What is the difference between them? Which one should I use when and why? Tomalak CurrentCulture is the .NET representation of the default user locale of the system. This controls default number and date formatting and the like. CurrentUICulture refers to the default user interface language, a setting introduced in Windows 2000. This is primarily regarding the UI localization/translation part of your app