Is it inappropriate to use InvariantCulture
? And, if used, would it affect any global settings?
Dim hh As Decimal = 123456789.123456
' Is this an appropriate usage?
Dim ll As String = hh.ToString("N4", CultureInfo.InvariantCulture)
Is it inappropriate to use InvariantCulture
? And, if used, would it affect any global settings?
Dim hh As Decimal = 123456789.123456
' Is this an appropriate usage?
Dim ll As String = hh.ToString("N4", CultureInfo.InvariantCulture)
Is using CultureInfo.InvariantCulture bad?
It entirely depends on what you're trying to achieve. If you're trying to format values to be machine-readable, it's almost always the right thing to do. If you're trying to format them for users, it may well be inappropriate.
Will it effect the global culture?
Specifying the invariant culture in a method call won't change the current thread's current culture, if that's what you're worried about.
Is using CultureInfo.InvariantCulture bad?
No. It exists for a reason. It allows you to parse text in a consistent, reliable manner, no matter what the current system culture happens to be.
However, it shouldn't be used (normally) to parse user input, but rather parsing text where you know it was written in the same manner that InvariantCulture expects.
© 2022 - 2024 — McMap. All rights reserved.