Answers for "convert object to byte[]"

1

hwo to convert list of custom class to a byte

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();
}
Posted by: Guest on December-14-2020

Browse Popular Code Answers by Language