Questions tagged [invariantculture]

Gets the CultureInfo object that is culture-independent (invariant).

48 questions
1
vote
1 answer

Is this safe, or will it only work in English-speaking countries?

I've got this code: Calendar cal = CultureInfo.InvariantCulture.Calendar; String dow = cal.GetDayOfWeek(DateTime.Now).ToString(); if (dow.Equals("Monday")) ...but I wonder if it would still work in German-speaking locales ("Montag") or…
1
vote
1 answer

property.GetValue ignores CultureInfo

It seems that for some reason property.GetValue ignores CultureInfo. Here is what I try to achieve: public static IEnumerable GetViewModelProperties(this IDocumentViewModel vm) { foreach (var property in…
Bolek Tekielski
  • 1,194
  • 2
  • 10
  • 25
1
vote
1 answer

StringComparison.InvariantCulture Clarification?

According To MSDN : StringComparison.InvariantCulture : Specifies the culture, case, and sort rules to be used by certain overloads of the String.Compare and String.Equals methods. Well , I'm not doing any sort here in my sample , And still…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
0
votes
0 answers

Parsing CultureInfo.InvariantCulture identifier

Let's say we have the following config: { "en": "something for english language", "de": "something for german language", "" : "something language independent" } By Microsoft documentation the identifier of Invariant culture is empty string,…
Rok
  • 451
  • 3
  • 21
0
votes
1 answer

My CultureInfo.InvariantCulture is not being invariant

I've got a very strange problem. My C# interactive gives me: > string.Format("{0:P1}", 0, CultureInfo.InvariantCulture) "0.0%" However, in the debugger, the same expression yields something else: > string.Format("{0:P1}", 0,…
chtenb
  • 14,924
  • 14
  • 78
  • 116
0
votes
3 answers

How does a values with decimal separators work with ToString with CultureInfo.InvariantCulture setting for Non english locale

I have a simple use case where I am using a system with German language set as system locale (regional format as German as well as current system locale as German). e.g. string sourceValue = "0,123"; string target_invariant =…
0
votes
2 answers

How to force .Net ToString to use given Globalization / CultureInfo

I'm working with a piece of .Net Core 6 library (dll), in which, amongst other functionality, numbers and date/time information is outputted as strings and this code is required to be globalized ie. to be culture-aware. The library is for a document…
tommijo
  • 43
  • 7
0
votes
1 answer

DateTime.TryParse with different culture

I have two dates as per below and have my local culture is "en-IN" string enInDateValue = "13-12-2021 12:00:00"; // dd/mm/yyyy string enUSDateValue = "12-13-2021 12:00:00"; // mm/dd/yyyy If I run the below code with Invariant Culture it date gets…
Anup Shah
  • 167
  • 1
  • 13
0
votes
0 answers

Convert string with German culture format to double using JsonConvert

I need to convert German format currency in a JSON (value may be negative or positive) to Double, I am able to do it using double.parse and specifying NumberStyle, something like below CultureInfo culture =…
0
votes
1 answer

C# DateTime Parse inconsistency

I´ve got a question about DateTime My Code is: DateTime.ParseExact("2018-06-13T12:05:55.7738391Z", "yyyy-MM-ddTHH:mm:ss.fffffffZ", System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ") The result…
0
votes
1 answer

Are .net SqlDataReader methods culture invariant

I can't really find a definitive answer to what happens if for example my decimals are stored in the database with different culture settings and I want to get them via a SqlDataReader into my program. Will the ',' and '.' always be correctly parsed…
user1246576
  • 51
  • 1
  • 8
0
votes
1 answer

ASP.NET MVC. Multilingual site. Set invariant culture for all DateTime's despite user's culture

I develop multilingual site. Users can change preferred language, so i set current culture for each request like so: System.Threading.Thread.CurrentThread.CurrentCulture = /* user preferred culture…
Sam Alekseev
  • 2,281
  • 2
  • 19
  • 28
0
votes
2 answers

C# Dictionary key lookup in an InvariantCulture way

My application handles some texts parsing and uses a proper noun cache to reduce database calls: Dictionary ProperNounsDict; if (!ProperNounsDict.ContainsKey(word)) { var newProper = new ProperNoun() { Word = word }; …
Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
0
votes
4 answers

Parsing a value with decimal points

I have a string value for amount that is coming from the DB. The local culture on my system is Portuguese(pt-br). As a result, the amount with decimal values is read as, for ex: 3,4 for 3.4. I need to parse this in such a way that it displays 3.4…
Akshatha
  • 592
  • 1
  • 11
  • 28
0
votes
1 answer

Relationship between StringComparer.OrdinalignoreCase and StringComparer.InvariantCultureIgnoreCase

I'm trying to get the relationship between results of string comparison when using StringComparer.OrdinalignoreCase and StringComparer.InvariantCultureIgnoreCase. More precisely I would like to know which of the following four statements is true: a…
Bartłomiej Siwek
  • 1,447
  • 2
  • 17
  • 26