Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (13 sloc) 925 Bytes

Allow digit separator after 0b or 0x

In C# 7.2, we extend the set of places that digit separators (the underscore character) can appear in integral literals. Beginning in C# 7.0, separators are permitted between the digits of a literal. Now, in C# 7.2, we also permit digit separators before the first significant digit of a binary or hexadecimal literal, after the prefix.

    123      // permitted in C# 1.0 and later
    1_2_3    // permitted in C# 7.0 and later
    0x1_2_3  // permitted in C# 7.0 and later
    0b101    // binary literals added in C# 7.0
    0b1_0_1  // permitted in C# 7.0 and later

    // in C# 7.2, _ is permitted after the `0x` or `0b`
    0x_1_2   // permitted in C# 7.2 and later
    0b_1_0_1 // permitted in C# 7.2 and later

We do not permit a decimal integer literal to have a leading underscore. A token such as _123 is an identifier.

You can’t perform that action at this time.