My C # ASP.Net program has an array of objects that populate during the postback, and I want to restore them during the next postback. To this end, I include the declaration of the array in the definition of the Default class, which is saved this way: -
this.Session["This"] = this;
and restored: -
Default saved_stuff = (Default) this.Session["This"];
This works great for everything except: -
MyClass [] my_array;
When restored, saved_stuff.my_array always null .
MyClass is defined as follows: -
public MyClass : ISerializable { private string some_string; private double some_double;
I tried to make MyClass implementation of ISerializable , but that doesn't make any difference. Does anyone know what I should do?
Edit to answer @Michael's question, then I do things like ...
for (int i = 0; i <= saved_stuff.my_array.GetUpperBound(0); i++) {
which fails with "object reference not set to object instance". All other Default member variables are displayed in saved_stuff when debugging.
source share