Function that converts hexadecimal to binary

Is there any function equivalent to Php's bin2hex() for C#?

I need to convert a hexadecimal to binary. I tried using TryParse but it hasn't worked out.

Author: Maniero, 2016-05-11

1 answers

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

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

See working on ideone. And no .NET Fiddle. Also I put on GitHub for future reference .

Documentation Convert.ToString() e Convert.ToInt32().

 5
Author: Maniero, 2020-10-23 20:29:21