Questions tagged [invariantculture]

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

48 questions
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
30
votes
4 answers

DateTime formats used in InvariantCulture

I have to pre-validate in Javascript a string that will be a DateTime in c#. The DateTime parse uses InvariantCulture. Does anyone know the DateTime formats defined for InvariantCulture?
nacho1493
  • 447
  • 1
  • 5
  • 11
11
votes
2 answers

CultureInfo.InvariantCulture in .ToString()

I am currently fixing FxCop issues so I encountered issue where I have to provide cultureinfo when converting a string using ToString() . Currently in my code nothing we are passing as IFormatProvider so I have read some msdn articles saying that…
user3766691
  • 143
  • 1
  • 3
  • 7
8
votes
2 answers

Locale invariant guarantee of boost::lexical_cast<>

I'm using boost::lexical_cast(double) for converting doubles to string, generating JSON serialized byte stream, that is (on remote side) parsed by .NET. I'm able to force the .NET to use InvariantCulture for parsing, thereby returning…
nothrow
  • 15,882
  • 9
  • 57
  • 104
4
votes
1 answer

ToLowerInvariant from a Kelvin Sign (K) in C# has different results

When I define the kelvin-sign (http://www.unicode-symbol.com/u/212A.html) like this: var kelvinSign = "K"; And do a console writeline: Console.WriteLine("{0} - {1}=>ToLower={2} - {3}=>ToLowerInvariant={4}", kelvinSign, …
Stef Heyenrath
  • 9,335
  • 12
  • 66
  • 121
4
votes
1 answer

When should I use StringComparison.InvariantCulture instead of StringComparison.CurrentCulture to test string equality?

Based on my understanding (see my other question), in order to decide whether to test string equality by using ordinal or cultural rules, the semantic of the performed comparison must be taken into account. If the two compared strings must be…
Enrico Massone
  • 6,464
  • 1
  • 28
  • 56
3
votes
1 answer

How to specify InvariantCulture in string.join()?

I have written the code below in which I am trying to convert an array of type double to a string value using string.join() method. And, then I am adding the string value as an attribute to an XML element. XElement element =…
skm
  • 5,015
  • 8
  • 43
  • 104
3
votes
3 answers

Decimal string without decimals, dots or commas in any culture

If I have a simple decimal in C#, and I want to ToString it without any dots, commas or decimals in any culture - how do i do it? I tried the ToString("N0") with invariantculture which removes decimals, but it adds "." in my language. What is the…
Lars Holdgaard
  • 9,496
  • 26
  • 102
  • 182
3
votes
4 answers

C# Parsing Date in "DDMMYYYY" format?

I am trying to parse a string date which is in DDMMYYYY format using following code but it is returning false even though 16062001 is a valid date in DDMMYYYY format. DateTime.TryParseExact("16062001", "DDMMYYYY",…
SamuraiJack
  • 5,131
  • 15
  • 89
  • 195
3
votes
1 answer

How to Set CultureInfo to InvariantCulture Classic ASP (VBScript)

I am looking for a way to set a Classic ASP page's Culture Info to Invariant Culture so that the decimals have a dot and not a comma. This gives me allot of issues, On windows 8 doesn't work, get it to work on windows 8, then it doesn't work on…
Pierre
  • 8,397
  • 4
  • 64
  • 80
3
votes
1 answer

Convert decimal under non-english Windows

I have installed C# application under Spanish MS Windows Server. So this code is working in a wrong way. decimal? top = 80.0m; double convertedTop = (double)decimal.Parse(top.ToString(), CultureInfo.InvariantCulture); convertedTop is 80000 but it…
NoWar
  • 36,338
  • 80
  • 323
  • 498
2
votes
3 answers

Write double to text file with dot separator

I need to write several doubles in text file with dot separator. I know, that this code is the solution: StreamWriter f = new StreamWriter(file, Encoding.ASCII, 128, false); double a = 1.057887; f.Write(a.ToString("G5",…
Perotto
  • 194
  • 1
  • 14
2
votes
2 answers

Using invariant culture with IFormatProvider in DateTime.ParseExact

In the First overload of ParseExact method public static DateTime ParseExact (string s, string format, IFormatProvider provider); according to Microsoft: If format is a custom format pattern that does not include date or time separators (such as…
Ammar
  • 91
  • 2
  • 13
2
votes
1 answer

Why are there no char.IsUpperInvariant / char.IsLowerInvariant methods?

Char implements the methods ToLowerInvariant and ToUpperInvariant to transform a character to upper/lower case independent of the current culture. However, there are no IsUpperInvariant and IsLowerInvariant methods. Why?
James Ko
  • 32,215
  • 30
  • 128
  • 239
2
votes
1 answer

Mono / XBuild Invariant Language (Invariant Culture) vs. VS2015 MSBuild's Neutral Language

I'm trying to resolve 2 discrepancies between the output of: Windows 8 / Visual Studio 2015 / MSBuild and Debian 8.2 / Mono Version 4.6.2.0 / XBuild Engine Version 14.0 Both of these issues are detailed in this example repo here:…
DavidWaugh
  • 275
  • 2
  • 9
1
2 3 4