📜  hwo 将自定义类列表转换为字节 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:23.250000             🧑  作者: Mango

代码示例1
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

byte[] bytes = null;
BinaryFormatter bf = new BinaryFormatter();
using (MemoryStream ms = new MemoryStream())
{
    //categoryList is where you put the list that you want to convert
    bf.Serialize(ms, categoryList);
    bytes = ms.ToArray();
}