User Tools

Site Tools

blog:2023-08-01_c_byte_to_string



2023-08-01 C#: byte to String

  • byte to ascii
  • 1
    2
    3
    byte[] c = new byte[2] { 0x41,0x61 };
    string s=Convert.ToChar(c[0]); => s="A";
    string s=Convert.ToChar(c[1]); => s="a";
  • byte to hex value string
  • 1
    2
    3
    byte[] c = new byte[2] { 0x41,0x61 };
    string s=c[0].ToString("X02"); => s="41";
    string s=c[1].ToString("X02"); => s="62";

TAGS

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

Permalink blog/2023-08-01_c_byte_to_string.txt · Last modified: 2023/08/01 14:47 by jethro

oeffentlich