User Tools

Site Tools

blog:2023-06-05_c_byte_to_text



2023-06-05 C#: byte to Text

  • Convert.ToChar is convert hex to the coressponded ascii code
  • Such the ascii code if 0x61 for 'a'

Detail

  • Example:
    byte[] b = new byte[2] { 0x41,0x42 };
    string s=Convert.ToChar(b[0]); => s="A";
    string s=Convert.ToChar(b[1]); => s="B";
  • if byte code want convert to the value
    byte[] b = new byte[2] { 0x41,0x42 };
    string s=b[0].ToString("X2"); => s="41";
    string s=b[1].ToString("X2"); => s="42";

TAGS

  • 36 person(s) visited this page until now.

Permalink blog/2023-06-05_c_byte_to_text.txt · Last modified: 2023/06/05 14:08 by jethro

oeffentlich