C# Digit Separator

New in C# 7 is the digit separator which is a handy little addition in C# 7 to keep those large numbers from making your eyes go all wonky! To use them, just add the underscore (_) character as a digit separator. Here is an example:

static void DigitSeparators()
{
     Console.WriteLine("=> Use Digit Separators:");
     Console.WriteLine("Integer {0}", 123_456);
     Console.WriteLine("Long: {0}", 123_456_789L);
     Console.WriteLine("Float: {0}", 123_456.1234F);
     Console.WriteLine("Double: {0}", 123_456.12);
     Console.WriteLine("Decimal: {0}", 123_456.12M);
}
digit separator screen shot

Leave a Reply

Your email address will not be published. Required fields are marked *