How to Group Digits of a Number for Formatting in C# ?

If you want to group the digits of a number for formatting to display in C# , one could use the “N” formatting option . Below is a code snippet demonstrating how to use it.

How to Group Digits of a Number for Formatting in C# ?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AbundantcodeConsoleApp
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //How to Group Digits of a Number for Formatting in C# ?
            int Input = 1165433;
            Console.WriteLine(Input.ToString("N", System.Globalization.CultureInfo.InvariantCulture));
            Console.ReadLine();
        }
    }
    
}

1
%d