|
-
Apr 22nd, 2003, 03:27 PM
#1
Thread Starter
I wonder how many charact
Simple question about Serializing classes
I'm using serialization to store the data in a collection of objects to disk....
Will this mean that every method in a class will be saved as well? I really only want to store the state of the properties, not the methods... (or does serialization only save the properties?)
I have looked thru my books, and can't tell for sure...
If serialization does save the method functions... how would one go about customizing the serialization to not include the methods...?
For example:
VB Code:
Public Class Style
Private styID As Int32
Public Property StyleID() As Int32
Public Sub New(ByVal StyleID As Int32, ByVal StyleName As String, ByVal ManufacturerID As Int32)
End Class
I really only want to save the StyleID, not the code for the constructor... does serialization save the constructor code to disk as well?
-
Apr 22nd, 2003, 03:28 PM
#2
Thread Starter
I wonder how many charact
Ah... nevermind, if Java doesn't serialize methods... I doubt .Net would either....
http://www.dnzone.com/ShowDetail.asp?NewsId=79
-
Apr 22nd, 2003, 03:31 PM
#3
Woldnt be any reason to anyway! Methods wouldnt need to be persisted.
-
Apr 22nd, 2003, 03:34 PM
#4
Thread Starter
I wonder how many charact
Yea, that was my gut reaction, but after sittin in front of code for 7 hours, you start seeing things move around your desk, forget to breathe, forget to use = New object.... im losing it... fast
-
Apr 22nd, 2003, 03:34 PM
#5
PowerPoster
Your right, serialization only serializes the variables of your class. If they are all value types, .Net will handle this for you with no problems. If the variables are other objects, those other objects need to be able to be serialized, or the serializer will choke.
The actual properties and methods are not serialized, just the class variables are.
-
Apr 22nd, 2003, 03:44 PM
#6
LOL. I swear that If statement just grew legs and ran off!
That is how I feel!
Thank god it is quittin time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|