B
Bob Bartel
I have a complex "query" object that I need to save to a table and then
restore. Everything works great with the following exception. When I try
to create a method within the object called Restore() and try to restore the
object onto itself I can't: Here's the code segment:
byte[] b = Convert.FromBase64String(SavedObjectString);
MemoryStream ms = new MemoryStream(b);
BinaryFormatter bf = new BinaryFormatter();
this = (query)bf.Deserialize(ms);
As you may know the "this" reference is read-only....yet I want to be able
to restore the object within itself. Is there a way to do this?
I have successfully restored the object by applying an instance variable:
query oQuery = new query();
byte[] b = Convert.FromBase64String(SavedObjectString);
MemoryStream ms = new MemoryStream(b);
BinaryFormatter bf = new BinaryFormatter();
oQuery = (query)bf.Deserialize(ms);
But the above code must be executed in another class so its not as helpful
as it could be if I could incorporate it into my query class.
Thanks in advance.
Bob
restore. Everything works great with the following exception. When I try
to create a method within the object called Restore() and try to restore the
object onto itself I can't: Here's the code segment:
byte[] b = Convert.FromBase64String(SavedObjectString);
MemoryStream ms = new MemoryStream(b);
BinaryFormatter bf = new BinaryFormatter();
this = (query)bf.Deserialize(ms);
As you may know the "this" reference is read-only....yet I want to be able
to restore the object within itself. Is there a way to do this?
I have successfully restored the object by applying an instance variable:
query oQuery = new query();
byte[] b = Convert.FromBase64String(SavedObjectString);
MemoryStream ms = new MemoryStream(b);
BinaryFormatter bf = new BinaryFormatter();
oQuery = (query)bf.Deserialize(ms);
But the above code must be executed in another class so its not as helpful
as it could be if I could incorporate it into my query class.
Thanks in advance.
Bob