RayofCommand
RayofCommand

Reputation: 4244

Powershell formatting in an culture independent way?! for numbers

When I use formatting for numbers bigger than 1000 like this :

"{0:F2}" -f 1000

I get this 1000.00 result for a US system language

and I get this 1000,00 result for a DE (german) system language.

Now I want to avoid that , without using replace ",","." or something.

So how to get a culture independent formatting?

Upvotes: 4

Views: 289

Answers (1)

Ocaso Protal
Ocaso Protal

Reputation: 20247

You could use ToString along with CultureInfo set to en-US, e.g.:

$a = New-Object System.Globalization.CultureInfo("en-US")
$b = 1000
$b.ToString("0.00", $a)

Upvotes: 2

Related Questions