Eliz
Eliz

Reputation: 7

separating decimal numbers with commas in asp.net eg:1,23,456

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");

Upvotes: 1

Views: 95

Answers (1)

Umesh Chaurasiya
Umesh Chaurasiya

Reputation: 173

I guess you can do this by creating a custom number format info for your needs...example is here for your reference -

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

    Response.Write("answer is : " + str);

Upvotes: 1

Related Questions