天天看點

字元串和ascii碼互相轉換

 //字元串轉換為ascii碼

 string s = "abc";

byte[] byteArray = new byte[s.Length];

byteArray = ASCIIEncoding.ASCII.GetBytes(s);

 string p = "";

for (int i = 0; i < byteArray.Length; i++)

{ p = p + byteArray[i]+","; }

s = p;

//ascii碼轉換為字元串

int aa = 44;

 byte[] ss = new byte[]{(byte)aa};

string sp=ASCIIEncoding.ASCII.GetString(ss);

s = sp;