Skip to content

Numeric literal leading underscores C# 7.2readability

Allow underscores to be used before the first digit in a numeric literal.

C# 7.0 gave us digit separators C# 7.0 but did not permit them to be used as the first digit in a literal.

C# 7.2 permits the _ character to also be used before the first numeric digit.

Code

C#
const int utf16bigEndian    = 0x_FE_FF;
const int utf16littleEndian = 0x_FF_FE;
C#
const int utf16bigEndian    = 0xFE_FF;
const int utf16littleEndian = 0xFF_FE;

More information