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?
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?
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 );
You could use an extension method:
public static int ToBinary(this string binary)
{
return Convert.ToInt32( binary, 2 );
}
However, whether this is wise I'll leave up to you (given the fact it will operate on any string).