c# class to byte array
// Convert an object to a byte array
private byte[] ObjectToByteArray(Object obj)
{
if(obj == null)
return null;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, obj);
return ms.ToArray();
}
// Convert a byte array to an Object
private Object ByteArrayToObject(byte[] arrBytes)
{
MemoryStream memStream = new MemoryStream();
BinaryFormatter binForm = new BinaryFormatter();
memStream.Write(arrBytes, 0, arrBytes.Length);
memStream.Seek(0, SeekOrigin.Begin);
Object obj = (Object) binForm.Deserialize(memStream);
return obj;
}
Also in C#:
- unity c# set gameobject active
- getcomponent c#
- what is the and in c#
- usermanager find based on role
- c# new dictionary linq
- c# inline initialize dictionary
- unity randomly generated numbers c#
- unity3d raycast
- c# read a webpage data
- unity separator in inspector
- c# unity rotate first person controller script
- iteration c#
- HashSet C# append
- check if current time is in the morning c#
- const float c#
- C# get all child classes of a class
- .net core authorizationhandlercontext
- unity key detection
- sum the digits in c#
- make a list c#
- how to name GameObject in c#
- Assets\playermove.cs(30,37): error CS1003: Syntax error, ',' expected
- count number of enum values C#
- c# math to radiant