cultureinfo

Convert number into culture specific

房东的猫 提交于 2019-12-07 22:31:29
I have a number like 202667.4 . I want to convert this to number based on culture . For Ex: In "de"(German) the number should be in 202.667,40 . Any help will be greatly appreciated. Thanks. If you want to represent existing number (say, double ) in culture specific format, try formatting : https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings double source = 202667.4; // "n" - ... group separators, and a decimal separator with optional negative sign // "de" - German culture string result = source.ToString("n", CultureInfo.GetCultureInfo("de")); Console

c# and Date Culture Problems

扶醉桌前 提交于 2019-12-07 12:40:44
问题 I've written a asp.net app and one of my postback routines simply saves user submitted form data to a sql 2005 db. All runs great on my development machine but when I deploy to the live site I'm getting invalid dates from my parse date checker. Basically it is expecting an american date format on the live machine but this is not what I want. The user needs to be able to enter in dd/MM/yyyy format. So a valid date like 21/10/2009 returns errors on live server but not on my dev machine. Below

Pass CurrentUICulture to Async Task in ASP.NET MVC 3.0

怎甘沉沦 提交于 2019-12-07 07:43:31
问题 The active language is determined from the url and then set on the Thread.CurrentThread.CurrentUICulture = cultureInfo; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cultureInfo.Name); That way the translations are retrieved from the correct resource files. When using Async action on controllers, we have a background thread, where the Thread.CurrentThread.CurrentUICulture is set back to OS default. But also on the background thread we need the correct language. I

Is this a good approach for temporarily changing the current thread's culture?

偶尔善良 提交于 2019-12-06 16:53:38
问题 I work on a fairly large ASP .NET Web Forms application that is currently used primarily in the United States. We are in the process of rolling it out to other parts of the world, which of course means we are currently working on localizing all areas of the application. Generally speaking our approach has been to set the current thread's CurrentCulture and CurrentUICulture properties at the beginning of each request to support the proper formatting and resource extraction based on the current

Currency Culture Formatting not applying on DataGridView Column

情到浓时终转凉″ 提交于 2019-12-06 14:21:20
I have 2 DataGridViews (DGV), and in both I have currency columns which I want to format. The code I'm writing seems to work in one, but not in the other. Both the DGV's are set up this way: Data is first loaded into a DataTable. A BindingSource then links to this DataTable. And lastly the DGV's use this BindingSource object for their data. I use the following code in the form's Load event to customize both DGVs' currency columns: dataGridView.Columns[columnIndexHere].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("de-DE"); dataGridView.Columns[columnIndexHere].DefaultCellStyle

C# format as currency with no trailing zero decimal numbers, consider negative, and different culture

我怕爱的太早我们不能终老 提交于 2019-12-06 13:50:13
问题 How can we format a number to currency without trailing zero decimal numbers? Basically it should behave as the "C" format specifier but without trailing zeroes. Below are the test cases. value | en-US | fr-FR 1 | $1 | 1 € 1.0 | $1 | 1 € 1.1 | $1.1 | 1,1 € 1.10 | $1.1 | 1,1 € -1 | ($1) | -1 € -1.0 | ($1) | -1 € -1.1 | ($1.1) | -1,1 € 1000 | $1,000 | 1 000 € 1000.0 | $1,000 | 1 000 € Is there a way to achieve this behavior by leveraging the "C" format specifier? side note: I am continuing from

WPF Default DateTime format

穿精又带淫゛_ 提交于 2019-12-06 08:05:05
问题 Working on a large WPF application and having some issues with the DateTime format, it's a huge codebase and many places do not specify the culture. When the user opens the application on Windows 7 or 8 the datetime format is different (Win 7 uses slashes and Win 8 uses dashes). I tried setting the Culture to "en-US" in the Application Startup (see below link) but it doesn't seem work? Setting Culture (en-IN) Globally in WPF App How do I set my WPF application to not use the culture of the

Automapper Mapping for Localization Resolver in a Multi-Language Website

和自甴很熟 提交于 2019-12-06 07:18:24
I found a way to use Automapper for Language mapping based on the active Culture. The question is if it's possible to build a generic Resolver to map all the models that use the Resolver. In this Case, the models to map have always the same properties, Id and Name (including the language properties Name_PT, Name_FR and Name_EN): // MODELS public class MakeDto { // Primary properties public int Id { get; set; } public string Name { get; set; } public string Name_PT { get; set; } public string Name_FR { get; set; } public string Name_EN { get; set; } } public class MakeViewModel { // Primary

Replace dot(.) with comma(,) using RegEx?

时光怂恿深爱的人放手 提交于 2019-12-05 23:36:04
问题 I am working on a C# application. I want to change number decimal figure with comma(,) where i have dot(.) using regular expression. For example: Price= 100,00.56 As this international rule of representing numeric values but I Sweden they have different ways for numbers Like Price= 100.00,56 So i want to change dot(.) into comma(,) and comma(,) into dot(.) using RegEx. Could guide me about this. 回答1: When formatting numbers, you should use the string format overload that takes a CultureInfo

Why isn't there a culture enum?

…衆ロ難τιáo~ 提交于 2019-12-05 20:47:02
问题 Greetings, I was wondering why there isn't a pre-set enum for cultures in C#? Since the cultures never change and are always like "nl-NL, en-GB, en-US".. why not make a enum for it to make things just a little bit easy'r ? [edit] As stated cultures do change.. but not all. Why not make a enum / class type which holds all the cultures and gives the possibility to add / change them ? 回答1: "Since the cultures never change" Don't they? This article (Microsoft .NET Framework 4: What is New in