C# binary constants representation

Andrei Rînea picture Andrei Rînea · Aug 7, 2009 · Viewed 11.4k times · Source

I am really stumped on this one. In C# there is a hexadecimal constants representation format as below :

int a = 0xAF2323F5;

is there a binary constants representation format?

Answer

Ed S. picture Ed S. · Aug 7, 2009

Nope, no binary literals in C#. You can of course parse a string in binary format using Convert.ToInt32, but I don't think that would be a great solution.

int bin = Convert.ToInt32( "1010", 2 );