Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting hexadecimal to binary

I want to Convert hexadecimal numbers to binary numbers.I search some posts but couldn't find a c# language program.

I used this:

value = 0xFFFF;
decimalNum = Convert.ToString(value, 16);
Console.WriteLine(value);

and then I converted it to binary number. Are there any easier and fast way to do this?

like image 809
AliTeo Avatar asked Nov 27 '25 11:11

AliTeo


1 Answers

You can do this:

var value = 0xFFFF; 
value = Convert.ToString(Convert.ToInt32(value.ToString(), 16), 2);
Console.WriteLine(value);
// 1100101010100110101
like image 120
Jonathan Carroll Avatar answered Nov 30 '25 01:11

Jonathan Carroll