0

I write this simple code to get data from socket:

private void DataReceive()
        {
            try
            {
                byte[] bytes = new byte[1000];
                int byteRec;

                while (true)
                {
                    while (true)
                    {
                        byteRec = handler.Receive(bytes);
                        if (byteRec > 0)
                        {
                            data = System.Text.Encoding.ASCII.GetString(bytes, 0, byteRec);
                            break;
                        }
                    }

                    FillLstMsg(data);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

but i want to get data from HEX format,or i see data in hex format?,how can i do this?

elnaz irani
  • 277
  • 1
  • 3
  • 11

1 Answers1

0

These links might help you out. These show the conversion from Byte to HEX. Even if this may not be exactly what you want, you might get the next step that you are looking for.

Get HEX string

Array conversion to HEX string

Hope this helps.

Community
  • 1
  • 1
Dhrumil
  • 3,221
  • 6
  • 21
  • 34