Why is it different from German and Swiss numbers by string conversion?

I'm just trying to convert a float that I read from Exel to a string using a comma as a decimal separator and two digits after a comma. I try the following code

$a = 707.63790474
$l = New-Object System.Globalization.CultureInfo("de-CH")
"CH: " + $a.ToString("F2", $l)


$l = New-Object System.Globalization.CultureInfo("de-DE")
"DE: " + $a.ToString("F2", $l)

$l = New-Object System.Globalization.CultureInfo("en-US")
"US: " + $a.ToString("F2", $l)

and get

CH: 707.64
DE: 707,64
US: 707.64

But as far as I know, a comma is used as a decimal separator in Switzerland, unless it is the currency cf. http://en.wikipedia.org/wiki/Decimal_mark . Did I miss something?

+5
source share
2 answers

Enter (New-Object System.Globalization.CultureInfo("de-CH")).numberFormatto get numberformatinfo for de-CH

You'll get:

CurrencyDecimalDigits    : 2
CurrencyDecimalSeparator : .
IsReadOnly               : False
CurrencyGroupSizes       : {3}
NumberGroupSizes         : {3}
PercentGroupSizes        : {3}
CurrencyGroupSeparator   : '
CurrencySymbol           : Fr.
NaNSymbol                : n. def.
CurrencyNegativePattern  : 2
NumberNegativePattern    : 1
PercentPositivePattern   : 1
PercentNegativePattern   : 1
NegativeInfinitySymbol   : -unendlich
NegativeSign             : -
NumberDecimalDigits      : 2
NumberDecimalSeparator   : .
NumberGroupSeparator     : '
CurrencyPositivePattern  : 2
PositiveInfinitySymbol   : +unendlich
PositiveSign             : +
PercentDecimalDigits     : 2
PercentDecimalSeparator  : .
PercentGroupSeparator    : '
PercentSymbol            : %
PerMilleSymbol           : 
NativeDigits             : {0, 1, 2, 3...}
DigitSubstitution        : None

As you can see, both NumberDecimalSeparator and CurrencyDecimalSeparator.

+2

All Articles