为什么德国和瑞士的数字与字符串转换不同?

ber*_*d_k 6 powershell formatting

我只是试图将我从Exel读取的浮点数转换为使用逗号作为小数点分隔符和逗号后面两位数的字符串.我尝试以下代码

$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)
Run Code Online (Sandbox Code Playgroud)

得到

CH: 707.64
DE: 707,64
US: 707.64
Run Code Online (Sandbox Code Playgroud)

但据我所知,瑞士使用逗号作为小数分隔符,除非它是货币cf. http://en.wikipedia.org/wiki/Decimal_mark.我错过了什么吗?

jon*_*n Z 2

输入(New-Object System.Globalization.CultureInfo("de-CH")).numberFormat以获取 de-CH 的 numberformatinfo

\n\n

你会得到:

\n\n
CurrencyDecimalDigits    : 2\nCurrencyDecimalSeparator : .\nIsReadOnly               : False\nCurrencyGroupSizes       : {3}\nNumberGroupSizes         : {3}\nPercentGroupSizes        : {3}\nCurrencyGroupSeparator   : \'\nCurrencySymbol           : Fr.\nNaNSymbol                : n. def.\nCurrencyNegativePattern  : 2\nNumberNegativePattern    : 1\nPercentPositivePattern   : 1\nPercentNegativePattern   : 1\nNegativeInfinitySymbol   : -unendlich\nNegativeSign             : -\nNumberDecimalDigits      : 2\nNumberDecimalSeparator   : .\nNumberGroupSeparator     : \'\nCurrencyPositivePattern  : 2\nPositiveInfinitySymbol   : +unendlich\nPositiveSign             : +\nPercentDecimalDigits     : 2\nPercentDecimalSeparator  : .\nPercentGroupSeparator    : \'\nPercentSymbol            : %\nPerMilleSymbol           : \xe2\x80\xb0\nNativeDigits             : {0, 1, 2, 3...}\nDigitSubstitution        : None\n
Run Code Online (Sandbox Code Playgroud)\n\n

如您所见,NumberDecimalSeparator 和CurrencyDecimalSeparator 都是。

\n