Converting string or byte to hex display

Hello, I really need a method, that converts array of bytes to hex, but not the WHOLE array, but only like array[1], array[3], etc.

1
2
3
4
5
6
7
8
9
10
public void showRecievedByte(Byte b, bool newCycle)
            {
                if (newCycle)
                {
                    comboBox1.Items.Clear();
                }
    
                comboBox1.Items.Add(System.Convert.ToString(b));
               
            } 

This method takes byte from array, for example `array[1]` (== 'a') and shows it as string 97 appears in comboBox1).
I would like this line:

comboBox1.Items.Add(System.Convert.ToString(b));

to be like:

comboBox1.Items.Add(StrToHex(System.Convert.ToString(b)));
or:

comboBox1.Items.Add(System.Convert.ToHex(b));

But I don't know yet how to make such function.
So I want to data from my array to be displayed in comboBox1 in Hex format.
I'm using Visual Studio 2010, but I did not found any implemented method. This is part of bigger C#/C++ project, it may looks strange but it is for test and learning purpose only.
Topic archived. No new replies allowed.