5

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?

2

1 Answer 1

16
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

Sign up to request clarification or add additional context in comments.

1 Comment

This Q has been marked as a duplicate. Your answer is better than the one in the other Q, you should post it there too!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.