All pastes #784868 Raw Edit

tobz

public text v1 · immutable
·published 2007-11-19 21:54 UTC
rendered paste body
public static byte[] GetSerializedObject(object obj)
		{
			MemoryStream outputStream = new MemoryStream();
			BinaryFormatter bFormatter = new BinaryFormatter();

			bFormatter.Serialize(outputStream, obj);

			return outputStream.ToArray();
		}

		public static object GetDeserializedObject(byte[] serializedObject)
		{
			MemoryStream inputStream = new MemoryStream(serializedObject);
			BinaryFormatter bFormatter = new BinaryFormatter();

			object obj = null;

			obj = bFormatter.Deserialize(inputStream);

			return obj;
		}