Convert integer to binary in c#
How do you convert integer numbers to binary representation?
I'm using this code
String input = "8";
String output = Convert.ToInt32(input, 2).ToString();
But it throws an exception.
Could not find any parsable digits
Best Answer
Your example includes an integer expressed as a string Let's say your integer was an integer and you want to take the integer and convert it to a binary string
int value = 8;
string binary = Convert.ToString(value, 2);
Which returns 1000.