Binary Literals −
Before C# 7 we were able to assign only decimal and hexadecimal values to a variable.
In C# 7.0 binary literal has been introduced and it allows us binary value to the variable.
Digit Separator −
Digit Separator takes the form of a single underscore (_). This separator can be used within any numeric literal as a means of improving legibility.
Example Binary Literals −
class Program{ public static void Main(){ var bn = 0b1000001; System.Console.WriteLine(bn.GetType()); System.Console.WriteLine(Convert.ToChar(bn)); Console.ReadLine(); } }
System.Int32 A
Example Digit Seperator −
class Program{ public static void Main(){ long Salary = 1_00_00_00_00_000; System.Console.WriteLine(Salary.GetType()); System.Console.WriteLine(Salary); Console.ReadLine(); } }
System.Int64 100000000000