根据目前的文化,我需要千位和小数分隔符。如果我们使用的是美国文化,那么对于小数,它应该是“。”它应该','。但是对于德国文化,默认的小数分隔符是','和千分隔符是'。'。获取日期时间分隔符我正在使用以下代码
CultureInfo us = new CultureInfo("en-US");
string shortUsDateFormatString = us.DateTimeFormat.ShortDatePattern;
string dateseparator= us.DateTimeFormat.DateSeparator;
string timeseparator= us.DateTimeFormat.TimeSeparator;
有没有像日期/时间一样的东西?
NumberFormat属性有货币和数字的这个信息。
您可以使用NumberFormat
的CultureInfo
属性,其中包含小数分隔符和千位分隔符的属性
var numberFormat = us.NumberFormat;
string decimalSeparator = numberFormat.NumberDecimalSeparator;
string thousandsSeparator = numberFormat.NumberGroupSeparator;
通过此代码可以获得当前的系统设置:
System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture;
FORMAT_NUMBER_DECIMALSEPARATOR = ci.NumberFormat.CurrencyDecimalSeparator;
FORMAT_NUMBER_DIGITGROUP = ci.NumberFormat.CurrencyGroupSeparator;