📅  最后修改于: 2022-03-11 14:55:23.250000             🧑  作者: Mango
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();
}