Converting string of binary to hex

18,013
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

Share:
18,013
user2020261
Author by

user2020261

Updated on June 04, 2022

Comments

  • user2020261
    user2020261 almost 2 years

    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?