Questions tagged [currentculture]

a Thread property in the .NET System.Threading namespace or a CultureInfo property in the .NET System.Globalization namespace

CurrentCulture refers to either the Thread.CurrentCulture property in the .NET System.Threading namespace or the CultureInfo.CurrentCulture property in the .NET System.Globalization namespace.

In both cases, this property is used to get or set the System.Globalization.CultureInfo object that represents the culture of the current thread.

Resources

Related Tags

139 questions
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
49
votes
11 answers

Best way to parse float?

What is the best way to parse a float in CSharp? I know about TryParse, but what I'm particularly wondering about is dots, commas etc. I'm having problems with my website. On my dev server, the ',' is for decimals, the '.' for separator. On the prod…
Boris Callens
  • 90,659
  • 85
  • 207
  • 305
46
votes
9 answers

Use "real" CultureInfo.CurrentCulture in WPF Binding, not CultureInfo from IetfLanguageTag

In my case: I have a TextBlock Binding to a property of type DateTime. I want it to be displayed as the Regional settings of the User says. I am setting Language property as WPF XAML…
Markus k
  • 513
  • 1
  • 4
  • 8
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
21
votes
4 answers

WinRT apps and Regional settings. The correct way to format dates and numbers based on the user's regional settings?

I'm having some problems in Windows 8 Metro apps (XAML & C#) regarding the user's regional settings. It seems that the apps won't respect user's regional settings, so even if your Windows 8 is set to display dates and times in Finnish format, the…
Mikael Koskinen
  • 12,306
  • 5
  • 48
  • 63
11
votes
1 answer

int.Parse of "8" fails. int.Parse always requires CultureInfo.InvariantCulture?

We develop an established software which works fine on all known computers except one. The problem is to parse strings that begin with "8". It seems like "8" in the beginning of a string is a reserved character. Parsing: int.Parse("8") -> Exception…
Henrik Carlsson
  • 343
  • 1
  • 3
  • 8
11
votes
3 answers

How to find the default dateformat of a Culture

Well, I am trying to get the default date format of a culture. For example en-us has "m/dd/yyyy" , en-uk 'd/mm/yyyy'. Culture could be anything at the client machine. and Dateformat can also be anything. like for Culture is en-us but dateformat is…
user1899600
  • 113
  • 1
  • 5
10
votes
3 answers

C# doubles show comma instead of period

I almost have the same problem as the guy in this thread: Convert Float that has period instead of comma? So that my double x = 234.4; string y = x.ToString(); I get y == "234,4"; Even worse ... Double.Parse("234.4") throws an exception. I have…
Presidenten
  • 6,327
  • 11
  • 45
  • 55
10
votes
1 answer

ArgumentOutOfRangeException using IndexOf with CultureInfo 1031

string s = "Gewerbegebiet Waldstraße"; //other possible input "Waldstrasse" int iFoundStart = s.IndexOf("strasse", StringComparison.CurrentCulture); if (iFoundStart > -1) s = s.Remove(iFoundStart, 7); I'm running CultureInfo 1031 (german).…
isHuman
  • 125
  • 9
10
votes
3 answers

CultureInfo.CurrentCulture is giving me the wrong culture

I'm trying to get my clients' country, so I use CultureInfo.CurrentCulture. Problem is that when my Canadian customers use my website, they're showing up as American. It looks like CultureInfo.CurrentCulture is returning my server's country instead…
thchaver
  • 111
  • 1
  • 1
  • 6
8
votes
1 answer

Does changing the culture of a threadpool thread affect it when it gets returned back to the pool?

If I set the CurrentCulture of a thread pool thread, what happens when the thread finishes execution and gets returned back to the thread pool? Does it get its CurrentCulture reset back to the default (whatever that may mean), or will it retain the…
adrianbanks
  • 81,306
  • 22
  • 176
  • 206
7
votes
1 answer

Is there a way to change the default thread culture in visual studio team service

I have a VSTS account within the region of US. And I have a bunch of Unit tests, which run successfully on my local server. But when deployed to the VSTS, all the tests related to the date time are failed. I guess this is because the interpretation…
7
votes
4 answers

Why is CurrentCulture a property of Thread?

It strikes me as an odd design choice that the current culture information (CurrentCulture and/or CurrentUICulture) is a a property of the running thread. At the very least it seems like the scope of such a thing should be one level up, at the…
I. J. Kennedy
  • 24,725
  • 16
  • 62
  • 87
7
votes
2 answers

Why doesn't the Timezone change when I set the CurrentCulture?

From what I have researched it is not possible to change the Timezone of a thread. So my question is why can't you? I would have thought switching your application's culture to a specific country would also switch this, seems like expected behaviour…
James
  • 80,725
  • 18
  • 167
  • 237
7
votes
4 answers

How to set CultureInfo.CurrentCulture?

Using: Console.WriteLine(System.Globalization.CultureInfo.CurrentCulture.ToString()); I get "en-US". What should I change in my control panel settings ( Region and Language ? ) to get something else for example "en-CA" .
user2740190
1
2 3
9 10