IFormatter formatter = new BinaryFormatter();
Stream stream = new MemoryStream();
formatter.Serialize(stream, history); // writes to the stream but leaves the pointer at the end of the stream
stream.Position = 0; // move the pointer back to the start of the stream before attempting to read
StreamReader reader = new StreamReader(stream);
txtHistorySerialized.Text = reader.ReadToEnd();
|