C# 中字符串string和字节数组byte[]的转换

2020-10-0221:40:04 评论 1,021 views

string转byte[]:

byte[] byteArray = System.Text.Encoding.Default.GetBytes(str);

byte[]转string:

string str = System.Text.Encoding.Default.GetString(byteArray);

string转ASCII byte[]:

byte[] byteArray = System.Text.Encoding.ASCII.GetBytes(str);

ASCII byte[]转string:

string str = System.Text.Encoding.ASCII.GetString(byteArray);

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: