Home>Article>Backend Development> What are the binary literal and number separators in C# 7.0?
Binary literals-
Before C# 7, we could only assign decimal and hexadecimal values to a variable.
Introduced in C# 7.0, binary literals allow us to pass binary values to variable.
Number separator-
The number separator takes the form of a single underscore (_). This separator can be used Can be used in any digital text as a way to improve legibility.
Binary Literal Example-
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
Number Separator Example-
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
The above is the detailed content of What are the binary literal and number separators in C# 7.0?. For more information, please follow other related articles on the PHP Chinese website!