Digit separator and binary literal

A new syntatic sugar has been added to C# 7, which is the digit separator. This construct greatly improves code readability, especially when handling large numbers of different numeric types supported in C#. Prior to C# 7, manipulating large numeric values to have separators was a bit messy and unreadable. With the introduction of the digit separator, you can now use an underscore (_) as a separator for digits:

var longDigit = 2_300_400_500_78;

Also newly introduced in this version is binary literals. You can now create binary literals by simply including 0b as a prefix to binary values:

var binaryValue = 0b11101011;

Get C# and .NET Core Test Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.