toxvaerd toxvaerd - 1 year ago 108
C# Question

C# binary literals

Is there a way to write binary literals in C#, like prefixing hexadecimal with 0x? 0b doesn't work.

If not, what is an easy way to do it? Some kind of string conversion?

Answer Source

C# 6.0 7.0 will be including support for binary literals (and optional digit separators).

Usage will look something like this:

Int32 myValue = 0b0010_0110_0000_0011;

You can also find more information on the Roslyn GitHub page.