Encoding类 表示字符编码 1.字符串转换成字节数组byte[] using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FileStreamTest { class Program { static void Main(string[] args) {
string weclome=""; byte[] data = new byte[1024]; //字符串转byte数组 data = Encoding.ASCII.GetBytes(welcome); //byte[]数组转ASCII字符串 weclome=Encoding.ASCII.GetString(data, 0, data.length)
使用默认字符集合 Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array. public byte[] getBytes() Constructs a new String by decoding the specified array of bytes using the platform's defau