Reputation: 14953
Does anyone know how to get number (or currency) format string (like "###,###,##0.00) from .NET NumberFormatInfo class? My research so far says that it should be constructed manually from the NumberFormatInfo class, but it sounds strange to me that Microsoft (or anyone else) didn't write anything for that purpose, so far.
Upvotes: 2
Views: 1867
Reputation: 57946
Try this:
var number = System.Globalization.CultureInfo.CurrentCulture.NumberFormat;
string format =
String.Format("{0}{1}{2}",
String.Join(
number.NumberGroupSeparator,
number.NumberGroupSizes.Select(group => new String('#', group))),
number.NumberDecimalSeparator,
new String('0', number.NumberDecimalDigits));
Upvotes: 3