Digit Separator



What is the digit separator in c#?

Sometimes, when we want to represent a big integer or long literal in code, its readability become difficult and there are chances to misspell a digit too. To avoid this error, With C# 7, Microsoft has introduced a digit separator. While it''s not the regular digit separator "comma (,)" which we use everywhere. It''s "underscore(_)".

Example:

using System;  
namespace DigitSeperator
{  
    class DigitSeperatorClass
    {  
        public static void Main(string[] args)  
        {  
            // Seperating digits
            int Money = 1_00_000;  
            double Popultion = 1_122_339_654;   
            Console.WriteLine(Money);  
            Console.WriteLine(Population);  
        }  
    }  
}  

Output:

100000
1122339654

0 Comment's

Comment Form