The C# digit separator represents a recent addition in C# 7.0, enabling the segregation of digits with a comma (,) for enhanced readability of numerical values.
When dealing with sizable numeric values, there is a risk of misinterpreting the number. To prevent such inaccuracies, C# introduces the concept of digit separators.
See, the upcoming sample that demonstrates this idea.
C# Digit Separator Example
Example
using System;
namespace CSharpFeatures
{
class DigitSeperatorExample
{
public static void Main(string[] args)
{
// Seperating digits using underscore
int i = 1_00_000;
double f = 1_00_000;
Console.WriteLine(i);
Console.WriteLine(f);
}
}
}
Output:
Output
100000
100000