Numeric Format Strings:N

LetterMeaning
NFixed point with numeric group separator

using System;
using System.Text;
using System.Globalization;
class Sample
{
    public static void Main()
    {
        Console.WriteLine("{0:N2}", 11111.2345);
        Console.WriteLine("{0:N2}", 11110.00001);

    }
}

The output:


11,111.23
11,110.00

N2 rounds values to two decimal places and add group (1,000s) separator.

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.