Serialization of Queue type- Serialization not working; C#

Posted by Soham on Stack Overflow See other posts from Stack Overflow or by Soham
Published on 2010-04-21T03:20:24Z Indexed on 2010/04/21 3:23 UTC
Read the original article Hit count: 719

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about c#

Related posts about sqlite3