Byte Array To Object - CSharp System

CSharp examples for System:Byte Array

Description

Byte Array To Object

Demo Code


using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.IO;/*from w w w . j  a  va2  s . co m*/
using System.Collections.Generic;
using System;

public class Main{
        // Convert a byte array to an Object
        public static Object ByteArrayToObject(byte[] arrBytes)
        {
            MemoryStream memStream = new MemoryStream();
            var binForm = new BinaryFormatter();
            memStream.Write(arrBytes, 0, arrBytes.Length);
            memStream.Seek(0, SeekOrigin.Begin);
            Object obj = (Object)binForm.Deserialize(memStream);
            return obj;
        }
}

Related Tutorials