Questions tagged [cultureinfo]

Represents information about a specific culture including the names of the culture, the writing system, and the calendar used, as well as access to culture-specific objects that provide information for common operations, such as formatting dates and sorting strings.

Represents information about a specific culture including the names of the culture, the writing system, and the calendar used, as well as access to culture-specific objects that provide information for common operations, such as formatting dates and sorting strings.

Reference

CultureInfo on MSDN

1135 questions
396
votes
5 answers

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

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…
splattne
  • 102,760
  • 52
  • 202
  • 249
298
votes
9 answers

How to use localization in C#

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?
JL.
  • 78,954
  • 126
  • 311
  • 459
183
votes
10 answers

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

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…
Svish
  • 152,914
  • 173
  • 462
  • 620
117
votes
20 answers

Find number of decimal places in decimal value regardless of culture

I'm wondering if there is a concise and accurate way to pull out the number of decimal places in a decimal value (as an int) that will be safe to use across different culture info? For example: 19.0 should return 1, 27.5999 should return 4, 19.12…
Jesse Carter
  • 20,062
  • 7
  • 64
  • 101
86
votes
5 answers

DateTime.TryParseExact() rejecting valid formats

I'm parsing a DateTime value in an ASP.NET WebForms page and the date string keeps getting rejected by the DateTime.TryParseExact() method even though it clearly matches one of the supplied format strings. It seems to fail on my development machine…
see sharper
  • 11,505
  • 8
  • 46
  • 65
77
votes
7 answers

DateTime.Now.DayOfWeek.ToString() with CultureInfo

I have the code: DateTime.Now.DayOfWeek.ToString() That give's me the english day of the week name, I want to have the german version, how to add CultureInfo here to get the german day of the week name?
PassionateDeveloper
  • 14,558
  • 34
  • 107
  • 176
74
votes
7 answers

Is Int32.ToString() culture-specific?

I'm running a beta version of ReSharper, and it's giving me warnings for the following code: int id; // ... DoSomethingWith(id.ToString()); The warning is on the id.ToString() call, and it's telling me "Specify a culture in string conversion…
Joe White
  • 94,807
  • 60
  • 220
  • 330
73
votes
6 answers

Get current language in CultureInfo

How to identify the operating system's language using CultureInfo? E.g. if the language in Windows is set to French, I need to identify French and load the fr resource files data.
Sharpeye500
  • 8,775
  • 25
  • 95
  • 143
65
votes
3 answers

how to set default culture info for entire c# application

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…
Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342
63
votes
7 answers

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

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",…
Jimmy
  • 5,131
  • 9
  • 55
  • 81
58
votes
8 answers

Get the currency from current culture?

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…
YodasMyDad
  • 9,248
  • 24
  • 76
  • 121
54
votes
3 answers

Could string comparisons really differ based on culture when the string is guaranteed not to change?

I'm reading encrypted credentials/connection strings from a config file. Resharper tells me, "String.IndexOf(string) is culture-specific here" on this line: if (line.Contains("host=")) { _host = line.Substring(line.IndexOf( "host=") +…
51
votes
4 answers

Culture invariant Decimal.TryParse()

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( …
Shaggydog
  • 3,456
  • 7
  • 33
  • 50
48
votes
18 answers

How to Convert Persian Digits in variable to English Digits Using Culture?

I want to change persian numbers which are saved in variable like this : string Value="۱۰۳۶۷۵۱"; to string Value="1036751"; How can I use easy way like culture info to do this please? my sample code is: List NERKHCOlist = new…
Amin AmiriDarban
  • 2,031
  • 4
  • 24
  • 32
47
votes
5 answers

Format string by CultureInfo

I want to show pound sign and the format 0.00 i.e £45.00, £4.10 . I am using the following statement: <%# Convert.ToString(Convert.ToSingle(Eval("tourOurPrice")) / Convert.ToInt32(Eval("noOfTickets")), new…
Waheed
  • 10,086
  • 20
  • 53
  • 66
1
2 3
75 76