© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•11mo ago•
10 replies
Faker

✅ How does CultureInfo works in C#?

Hello guys, it's been quite a few instances now that I came across CultureInfo. I encounted it when comparing strings and when comparing dates. What I understood about it is that, if we don't specify anything, it uses the locale system of our machine. So if our machine is set to
en-us
en-us
and we try to compare something with
de-DE
de-DE
, their might be issues here? I know the "ß (Eszett)" stands for "ss" I think... so, what kind of issues might arise?

If we write something like this for eg:

var str1 = "Grasse";
var str2 = "Graße"
if (str1 == str2) ...
var str1 = "Grasse";
var str2 = "Graße"
if (str1 == str2) ...

str1 == str2 will return false in this case (If we don't change the CultureInfo thing)?

Now there is also the CultureInfo when we use dates. This is where I'm the most confused. When we use methods like
TryParse
TryParse
with DateOnly, it may happen that the overload contains the IFormatProvider interface, so basically these are "settings" to change the culture specific.

For string I did understand what it does (but please someone confirm if the above statements are correct please.), for date, it's a bit ambiguous though. So say my locale system has culture
en-us
en-us
, basically, this mean that my date format is specific to the us culture. How will that affect my
TryParse
TryParse
or
TryParseExact
TryParseExact
?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Does CultureInfo ever matter here?
C#CC# / help
3y ago
❔ P/Invoked DeviceIoControl() works in C++ but does nothing in C#.
C#CC# / help
3y ago
✅ How does dependencies works ?
C#CC# / help
15mo ago
How does managed C++ work for interoping with C# code?
C#CC# / help
2y ago