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
46
votes
3 answers

Convert any currency string to double

I need to store multiple currencies in SQL server. I understand that SQL won't support all different types of currencies (unless I store it as a string, but I don't want to do that). My idea was to convert all the values from their currency format…
James
  • 80,725
  • 18
  • 167
  • 237
39
votes
3 answers

Difference between CultureInfo.CreateSpecificCulture() and the constructor of the class?

The class CultureInfo provides two way of creation: via a factory method CreateSpecificCulture(string). via a constructor with a string argument The MSDN documentation does slightly differ for the two, mentioning some "Windows culture" for the…
Marcel
  • 15,039
  • 20
  • 92
  • 150
35
votes
6 answers

Setting Culture (en-IN) globally in WPF application

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…
Varun Jain
  • 1,015
  • 2
  • 13
  • 19
34
votes
8 answers

Programmatic way to get all the available languages (in satellite assemblies)

I'm designing a multilingual application using .resx files. I have a few files like GlobalStrings.resx, GlobalStrings.es.resx, GlobalStrings.en.resx, etc. When I want to use this, I just need to set Thread.CurrentThread.CurrentCulture. The…
Tute
  • 6,943
  • 12
  • 51
  • 61
31
votes
2 answers

How to produce localized date string with CultureInfo

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…
Keith
  • 1,959
  • 10
  • 35
  • 46
30
votes
2 answers

culture invariant object ToString()

How can I call ToString() on an object and make it use the invariant culture? There are overloads for ToString() on objects that implement IConvertible (like bool, int, float..), but what if the object in question is not IConvertible?
codymanix
  • 28,510
  • 21
  • 92
  • 151
30
votes
3 answers

DateTime.ParseExact() does not grok 24-hour time values?

This line of code: DateTime dt = DateTime.ParseExact(time, "hh:mm", CultureInfo.InvariantCulture); parses a "time" value of "12:45" just fine, but throws an exception of "13:00" Should I be using some other CultureInfo value, or do I need to append…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
29
votes
5 answers

How to print DateTime in Persian format in C#

What is the simplest way to print c# DateTime in Persian? currently I'm using : static public string PersianDateString(DateTime d) { CultureInfo faIR = new CultureInfo("fa-IR"); faIR.DateTimeFormat.Calendar = new PersianCalendar(); …
user590747
  • 345
  • 1
  • 4
  • 9
29
votes
4 answers

DateTime and CultureInfo

I have this in my code: var date1 = DateTime.ParseExact(date, "dd.MM.yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); And when my current cultur is dutch (nl-NL) instead of May 1st I get January 5th. I think the error is in the…
petko_stankoski
  • 10,459
  • 41
  • 127
  • 231
27
votes
4 answers

Is it possible to set the CultureInfo for an .NET application or just a thread?

I've an application written in C# which has no GUI or UI, but instead writes files that are parsed by another application (in XML and others). I have a customer whose CultureInfo has the NumberDecimalSeparator set to a comma, which causes parsing…
NVRAM
  • 6,947
  • 10
  • 41
  • 44
26
votes
8 answers

How to get current regional settings in C#?

Normally you can get it by writing something like CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; But this way you can only get CultureInfo which was configured at the moment application was launched and will not update if the…
Shuric
  • 327
  • 1
  • 4
  • 8
24
votes
2 answers

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

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…
Jesse Taber
  • 2,376
  • 3
  • 23
  • 33
22
votes
4 answers

Passing a DateTime to controller via URL causing error in ASP .NET MVC 3 (culture)

My application is setted with pt-BR culture (Date is dd-mm-yyyy) in web.config:
Paul
  • 12,359
  • 20
  • 64
  • 101
22
votes
2 answers

When should I specify CurrentCulture or InvariantCulture and when should I leave it unspecified?

What is the best practice for specifying CurrentCulture or InvariantCulture and not specifying the culture at all? From what I have read, if you're doing serialization, for instance, you need InvariantCulture as a means of specifying a canonical…
Scott Stafford
  • 43,764
  • 28
  • 129
  • 177
22
votes
2 answers

StreamWriter and IFormatProvider

How do I pass an IFormatProvider to a StreamWriter? Specifically I want to create a new StreamWriter("myfile.txt", CultureInfo.InvariantCulture); TextWriter and StringWriter have a parameter for that in the constructor, but StreamWriter does…
HugoRune
  • 13,157
  • 7
  • 69
  • 144
1
2
3
75 76