//-----------------------------------------------------------------------
//
// Copyright (c) ParanoidMike. All rights reserved.
//
//-----------------------------------------------------------------------
namespace ParanoidMike
{
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Microsoft.Win32;
///
/// Reusable functions for many uses.
///
public static class Utility
{
///
/// Convert a byte array to an Object.
/// Copied from http://snippets.dzone.com/posts/show/3897
///
///
/// The byte[] array to be converted.
///
///
/// The object to which the byte array is converted.
///
public static 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;
}
}
}