Home » C#

C# | Custom formatting of integer numbers using String.Format() method

C# | String.Format() method with Example: Here, we are going to learn about the custom formatting of integer numbers in C#.
Submitted by IncludeHelp, on November 01, 2019

Here is the some of the examples of custom formatting of an integer numbers in C#.

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Demo for custom formatting of an integer number:");

            Console.WriteLine(String.Format("{0:+#### #### ####}" ,  1234567891012));
            Console.WriteLine(String.Format("{0:##-##-####}", 21102019));
            Console.WriteLine(String.Format("{0:##/##/####}", 21102019));
            
            Console.WriteLine();  
        }
    }
}

Output

Demo for custom formatting of an integer number:
+12345 6789 1012
21-10-2019
21/10/2019

In the above program, we printed sign '+' and printed the numbers in 4 digits three times. And here we printed the date also with symbol '-' and '/'.






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.