ASP.NET - how to display number with commas and decimal points?

Asked By Rossy D on 04-Jun-15 03:22 AM
 i tried this format, got output as 1,234,567,890.00 but i need  in this format  1,23,567 

decimal unitPrice = 1234567890.00m;
TextBox1.Text = Convert.ToDecimal(unitPrice).ToString("##,#0.00");


        

Robbe Morris replied to Rossy D on 04-Jun-15 08:51 AM
Look up setting the current thread's CultureInfo.  It is what drives this sort of thing off the formats.
Rossy D replied to Robbe Morris on 06-Jun-15 01:39 AM
i tried but its not working out, can yu Please help me to sort out this asap !

Thanks in advance !
Rossy D replied to Robbe Morris on 06-Jun-15 02:35 AM
Hi Mr.Robbe
              i just tried below method. Its working, thank yu very much !


       int yourNumber = 11123423;
        NumberFormatInfo nfo = new NumberFormatInfo();
        nfo.CurrencyGroupSeparator = ",";
        nfo.NumberGroupSizes = new int[] { 3, 2 };
       string str = yourNumber.ToString("N0", nfo);