Serialization of Queue type- Serialization not working; C#
- by Soham
Hi All,
Consider this piece of code:
private Queue Date=new Queue();
//other declarations
public DateTime _Date {
get { return (DateTime)Date.Peek();}
set { Date.Enqueue(value); }
}
//other properties and stuff....
public void UpdatePosition(...)
{
//other code
IFormatter formatter = new BinaryFormatter();
Stream Datestream = new MemoryStream();
formatter.Serialize(Datestream, Date);
byte[] Datebin = new byte[2048];
Datestream.Read(Datebin,0,2048);
//Debug-Bug
Console.WriteLine(Convert.ToString(this._Date));
Console.WriteLine(BitConverter.ToString(Datebin, 0, 3));
//other code
}
The output of the first writeline is perfect. I.e to check if really the Queue is initialised or not. It is. The right variables are stored and et. all [I inserted a value in that Q, that part of the code is not shown]
But the second writeline is not giving the right expected answer: It serializes the entire Queue to 00-00-00.
Want some serious help!
Soham