Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting string of binary to hex [duplicate]

Tags:

c#

hex

binary

Possible Duplicate:
Converting long string of binary to hex c#

nyI'm looking for a way to convert a string of binary to a hex string.

the binary string has four positions. the binary string looks something like this

string binarystring= "1011";

output string should be like this

output string="B";

is there any way to convert a string of binary into hex?

like image 384
user2020261 Avatar asked Dec 09 '22 18:12

user2020261


1 Answers

Convert.ToInt32("1011", 2).ToString("X");

For more information about the string value used with ToString() as its parameter, check the following documentation:

https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx

like image 158
Soroush Falahati Avatar answered Dec 11 '22 08:12

Soroush Falahati