Function that converts hexadecimal to binary

4

Is there a function equivalent to bin2hex() of PHP for C #?

I need to convert a hexadecimal to binary. I tried to use TryParse but it did not work.

    
asked by anonymous 11.05.2016 / 17:23

1 answer

4

Yes, the type conversion functions allow you to use the base you need:

Convert.ToString(Convert.ToInt32("4F56A", 16), 2)

See running on dotNetFiddle and CodingGround .

Documentation Convert.ToString() and Convert.ToInt32() .

    
11.05.2016 / 17:30