Custom Numeric Formatting: Escapes and Literals ({0:###\\#}) : Number format « Data Type « C# / CSharp Tutorial






using System;
class Test
{
    public static void Main()
    {
        Console.WriteLine("{0:###\\#}", 255);
        Console.WriteLine(@"{0:###\#}", 255);
        Console.WriteLine("{0:###'#0%;'}", 1456);
    }
}
255#
255#
1456#0%;








2.55.Number format
2.55.1.To format numeric data
2.55.2.Numeric Formatting: Decimal ({0:D}, {0:D7})
2.55.3.Numeric Formatting: Fixed-Point ({0:F}, {0:F0}, {0:F5})
2.55.4.Numeric Formatting: General ({0:G}, {0:G7}, {0:G4})
2.55.5.Numeric Formatting: Number ({0:N}, {0:N4})
2.55.6.Numeric Formatting: Scientific (Exponential) ({0:E}, {0:E10}, {0:e4})
2.55.7.Custom Numeric Formatting: Decimal Point ({0:#####.000}, {0:##.000})
2.55.8.Custom Numeric Formatting: Digit or Space Placeholder ({0:#####}, {0:###})
2.55.9.Custom Numeric Formatting: Digit or Zero Placeholder ({0:000})
2.55.10.Custom Numeric Formatting: Escapes and Literals ({0:###\\#})
2.55.11.Custom Numeric Formatting: Exponential Notation ({0:###.000E-00}, {0:#.0000000E+000})
2.55.12.Custom Numeric Formatting: Group Separator ({0:##,###}, {0:##,000.000})
2.55.13.Custom Numeric Formatting: Number Prescaler ({0:000,,,.###})
2.55.14.Custom Numeric Formatting: Percent Notation ({0:##.000%})
2.55.15.Custom Numeric Formatting: Section Separator ({0:###.00;0;(###.00)})
2.55.16.Format number: C, D9, E, F3, N, X, x