1

I would like to print out UInt32 as ##,##,##.
Comma every two digits.
Is there a way to do this?

ToString("N0");  

Is a comma every three digits

paparazzo
  • 44,497
  • 23
  • 105
  • 176

1 Answers1

5

You should be able to use (with using System.Globalization;):

yourUInt.ToString("N0", new NumberFormatInfo { NumberGroupSizes = new[] { 2, }, })

Documentation: NumberGroupSizes property


Of course, this NumberGroupSizes property can also be set on the NumberFormat property of a CultureInfo (possibly obtained by cloning an existing read-only CultureInfo) which can then be assigned to System.Threading.Thread.CurrentThread.CurrentCulture.

Jeppe Stig Nielsen
  • 60,409
  • 11
  • 110
  • 181