Right number format for million value

T.Zacks 3,996 Reputation points
2021-04-28T10:06:02.943+00:00
            int number = 25226;
            string abc = string.Format("{0:#,0}", number);
            abc = string.Format("{0:#,0}", 1122450); //1,122,450

when i applied this format for million value string.Format("{0:#,0}", 1122450); then output comes like 1,122,450 which is not right. so tell me best format which works fine for thousand and million value. thanks

Developer technologies | C#
{count} votes

Accepted answer
  1. Viorel 122.7K Reputation points
    2021-04-28T17:44:16.37+00:00

    Check an example:

    var c = CultureInfo.GetCultureInfo( "en-IN" );
    decimal n = 1122450;
    string s = n.ToString( "#,0", c );
    Console.WriteLine( s ); // "11,22,450"
    

    Use the language name which is more appropriate.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.