之前以为BinaryWriter写string会严格按构造时指定的编码(不指定则是无BOM的UTF8)写入string的二进制,如下面的代码: //将字符串"a"写入流,再拿到流的字节组data using (var ms = new MemoryStream()) { using (var bw = new BinaryWriter(ms)) { bw.Write("a"); } byte[] data = ms.ToArray(); } 因为字母a的utf8编码…
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication1 { public class INFO { public Int32 a { get; set; } public string b { get; set; } public string c { get; set; } public…