我怎么能转换为例如byte[] b = new byte[1]; b[1]=255字符串?我需要一个值为"255"的字符串变量,string text= "255";然后将其存储在文本文件中?
Gre*_*mar 11
从字节开始:
byte[] b = new byte[255];
string s = Encoding.UTF8.GetString(b);
File.WriteAllText("myFile.txt", s);
Run Code Online (Sandbox Code Playgroud)
如果你从字符串开始:
string x = "255";
byte[] y = Encoding.UTF8.GetBytes(x);
File.WriteAllBytes("myFile2.txt", y);
Run Code Online (Sandbox Code Playgroud)