I have in my C# ASP.Net program an array of objects that are filled in during a postback and I wish to recover them during the next postback. To this end I include the array declaration in the Default class definition which is saved thus:-
this.Session["This"] = this;
and recovered:-
Default saved_stuff = (Default) this.Session["This"];
This works fine for everything apart from:-
MyClass [] my_array;
When recovered, saved_stuff.my_array
is always null
.
MyClass is defined like this:-
public MyClass : ISerializable
{
private string some_string;
private double some_double;
// some more simple members
// Some getters and setters
// ISerializable Implementation
}
I have tried making MyClass
implement ISerializable
but that doesn't make any difference. Does anyone know what I should be doing?
Edit to answer @Michael's question, I'm then doing things like...
for (int i = 0; i <= saved_stuff.my_array.GetUpperBound(0); i++)
{
// blah blah
}
which is failing with "object reference is not set to an instance of an object". All the other member variables of Default
are visible in saved_stuff
when in debug.