Menu

Sunday, 30 November 2014

Literals and Seperators in C# 6.0


This feature is very helpful to write more readable code while initializing properties and variables for numerical values with new syntax for byte and long types.

Binary:
The new syntax for declaring binary property now, you can use 0b as a prefix.
public byte BinaryCode {get; } =  0b1010; 

Long:
The new syntax for declaring long type property to provide ability to use underscore (_) as a separator. Its much easier to look at the value like billions or millions etc.
public long Number {get; } = 1_000_000_000;

No comments:

Post a Comment