cultureinfo

Why does Parallel.ForEach change the culture of its threads?

随声附和 提交于 2020-01-03 17:09:15
问题 Today I came across a strange phenomenon I can't really explain. There's a webpage with a number of rows in a gridview, which need to be saved to the database and to an XML file one by one. I ended up using a Parallel.ForEach , as there is no relation between the rows, so they can be executed independently. The code is basically this: Parallel.ForEach(gvWithData.Rows.Cast<GridViewRow>(), row => { if (row.RowType == DataControlRowType.DataRow) { // do some logic and stuff... var type = new

Can CultureInfo.CurrentCulture ever be null?

本小妞迷上赌 提交于 2020-01-03 07:19:31
问题 Can CultureInfo.CurrentCulture ever be null? A null value would crash my program, which I don't want. So I'm asking, to be safe, do I need to do? var culture = CultureInfo.CurrentCulture ?? CultureInfo.InvariantCulture 回答1: It definitely looks like it's guaranteed to be non- null : The culture is a property of the executing thread. This read-only property is equivalent to retrieving the CultureInfo object returned by the Thread.CurrentCulture property. Thread.CurrentCulture throws an

Why is the culture name for English (Caribbean) “en-029”?

吃可爱长大的小学妹 提交于 2020-01-03 07:19:20
问题 Why is the culture name for English (Caribbean) "en-029"? I know "en-CA" is used for English (Canada), but why 029? What does it signify? Why was it chosen? 回答1: Michael Kaplan (aka Microsoft's Unicode guru) just wrote a blog post about that last week. EDIT And actually, if you read the comments you'll see that 029 isn't even an ISO 3166 code because ISO 3166 is only about countries. That's where UN M.49 comes in which defines codes that specify: a wide variety of geographical, political, or

Can CultureInfo.CurrentCulture ever be null?

六眼飞鱼酱① 提交于 2020-01-03 07:19:19
问题 Can CultureInfo.CurrentCulture ever be null? A null value would crash my program, which I don't want. So I'm asking, to be safe, do I need to do? var culture = CultureInfo.CurrentCulture ?? CultureInfo.InvariantCulture 回答1: It definitely looks like it's guaranteed to be non- null : The culture is a property of the executing thread. This read-only property is equivalent to retrieving the CultureInfo object returned by the Thread.CurrentCulture property. Thread.CurrentCulture throws an

CultureInfo thread safety

我与影子孤独终老i 提交于 2020-01-02 01:04:44
问题 I have a multi-threaded application which parses some text and it needs to use English Culture Info for parsing numbers from this text. So, i do not want to create EngCulture everytime i call the parsing function. Currently i am passing EngCulture as a parameter but i am not happy with this. I want to define the EngCulture as a static member so it will be shared by threads. Msdn documentation says that "Any public static (Shared in Visual Basic) members of this type are thread safe. Any

Units of distance for the current CultureInfo in .Net

℡╲_俬逩灬. 提交于 2020-01-01 08:24:05
问题 Is it possible to get the unit of distance from a CultureInfo class or any other class in the System.Globalization namespace. e.g. "en-GB" would be "mile", "en-FR" would be "km" 回答1: RegionInfo.CurrentRegion.IsMetric 来源: https://stackoverflow.com/questions/6020359/units-of-distance-for-the-current-cultureinfo-in-net

How do I display Nigerian Naira symbol in CultureInfo(c#)

老子叫甜甜 提交于 2019-12-30 10:37:26
问题 I want to display an amount with the Nigerian currency symbol (i.e N with double strike through " ₦ "). I've tried the ff piece of code which only displays the amount with just N and not with the properly symbol(N with double strike through ₦ ) @{ IFormatProvider currencyFormat = new System.Globalization.CultureInfo("HA-LATN-NG"); } Amount: @string.Format(currencyFormat, "{0:c}", Model.Amount) <br /> Any ideas how to achieve it? 回答1: It looks like the built-in nigerian cultures have a

How to produce localized date string with CultureInfo

三世轮回 提交于 2019-12-28 06:28:08
问题 I have the following code that produces a date string in en-us format. I would like to pass in the LCID (or equivalent value for the localized language) to produce the localized version of the date string. How would I accomplish this? public static string ConvertDateTimeToDate(string dateTimeString) { CultureInfo culture = CultureInfo.InvariantCulture; DateTime dt = DateTime.MinValue; if (DateTime.TryParse(dateTimeString, out dt)) { return dt.ToShortDateString(); } return dateTimeString; }

Setting Culture (en-IN) globally in WPF application

自作多情 提交于 2019-12-27 17:37:45
问题 I have an application, which is based for India, and I'm setting Culture as: Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-IN"); The above code is called before the Window.InitializeComponent() method is called. Still this is showing $ as CurrencySymbol in all TextBoxes. If I bind a TextBox as following, it shows Rs. as CurrencySymbol: Text="{Binding Salary,Mode=TwoWay,StringFormat=C,ConvertCulture=en-IN}". 回答1: I think you will need to add the following. Thread.CurrentThread

Swedish characters (åäö) not working on webserver but works on local computer

我怕爱的太早我们不能终老 提交于 2019-12-25 09:48:25
问题 As the headline says I have some strange problem of getting the special characters to work on the webserver but they show properly when I run the homepage from my local computer. Using visual studio express 2012 for web. .NET framework is verison 4.5.51209. In the aspx.vb file I change the Culture using. System.Threading.Thread.CurrentThread.CurrentCulture = New CultureInfo("sv-SE") And in the aspx file I have this code telling it should use UTF-8. Page Language="VB" Culture="sv-SE"