C# 7.0 introduces Number literals as well as Binary Literals
These are completely new features that adds syntactic sugar to C# while dealing with number and binary data.
You can now declare numeric variables as below while adding (Underscore) _ as a separator for readability. This is handy while dealing with large numbers
One important thing to understand about these separator literals is that these are ignored by compiler while evaluating the value and are just meant to provide readability.
int number = 123456; //Before C# 7.0 style number = 123_456; //C# 7.0 style separator
Similar feature can be used with binary/Hexadecimal numbers to clearly define bit patterns
style="display:block; text-align:center;"
data-ad-format="fluid"
data-ad-layout="in-article"
data-ad-client="ca-pub-5021110436373536"
data-ad-slot="9215486331">
var binaryNumber = 0b1000_0001_1100_0111_1110_1000_1100; var hexNumber = 0x12_d6_87; double realNumber = 2_000.311_1e-1_000; Console.WriteLine(number);//Prints 123456 ignoring _ Console.WriteLine(binaryNumber);//Prints 136085132 ignoring _ Console.WriteLine(hexNumber);//Prints 1234567 ignoring _ Console.WriteLine(realNumber);//Prints 0 ignoring _
All code samples are available at my GitHub profile
I am a corporate trainer and solution architect and have a great team of software professionals. Please contact in case you need our services by sending email to contact@techprocompsoft.com. Here is our company website .