serialization - C# Deserializing a List of custom objects returns null -


i have class called "itemtoplace"

[serializable()] private class itemtoplace {     public itemtoplace(int id, float x, float y)     {         this.id = id;         this.x = x;         this.y = y;     }      public itemtoplace()     {      }      public int id { get; set; }     public float x { get; set; }     public float y { get; set; } } 

and have

list<itemtoplace> items; 

i serialize list follows:

stream stream = file.open("data.dat", filemode.create); binaryformatter bformatter = new binaryformatter(); bformatter.serialize(stream, items); stream.close(); 

deserializing list returns null

 stream stream = file.open("data.dat", filemode.open);  binaryformatter bformatter = new binaryformatter();   // level = null  level = bformatter.deserialize(stream) list<itemtoplace>;  stream.close(); 

i have no clue why not working! hint nice!


Comments