By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,554 Members | 1,569 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,554 IT Pros & Developers. It's quick & easy.

Collection Class Serialization

P: n/a
Can anyone point me to a collection class that has
serialization/deserialization with it - preferably in XML.

I know this can't be done with a collection that inherits from
CollectionBase, but I'm hoping someone has another collection class out
there.

Thanks;
Michael
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Michael,
Can anyone point me to a collection class that has
serialization/deserialization with it - preferably in XML.

This has only one answer. The dataset.

Cor
Nov 21 '05 #2

P: n/a
Michael,

Both arraylist and hashtable can be serialized with a binaryformatter. I
think that arraylist can also be serialized as xml.

I'm surprised that collectionbase is not serializable. Are you sure about
that?

Kerry Moorman
"Michael Rich" wrote:
Can anyone point me to a collection class that has
serialization/deserialization with it - preferably in XML.

I know this can't be done with a collection that inherits from
CollectionBase, but I'm hoping someone has another collection class out
there.

Thanks;
Michael

Nov 21 '05 #3

P: n/a
J L
Strange coincidence...as a newbie I was trying various things today
and one was serializing both a HashTable and a SortedList. Both can be
serialized to XML via SOAP. In fact, I placed my Person objects (just
a dumb class I created for learning purposes) and was able to
serialize and deserialize the objects. Not sure how I am going to use
it yet but it was cool.

Here is an example of writing:

Dim sl As New SortedList
Dim John As Person
Dim Mary As Person
Dim Joe As Employee ' employee inherits from Person

John.Name = "John"
John.BirthDay = "01/01/2000"
<etc>

sl.Add(John.BirthDate, John)
sl.Add(Mary.BirthDate, Mary)
sl.Add(Joe.BirthDate, Joe)

Dim formatter As New Soap.SoapFormatter
Dim saveFile As New FileStream

saveFile = File.OpenWrite("C:\ATest.txt")
formatter.Serialize(saveFile, sl)
saveFile.close()

And here is how to read it:

Dim sl As New SortedList
Dim Formatter As New Soap.SoapFormatter
Dim readFile As New FileStream
readFile = File.OpenRead("C:\ATest.txt")
sl = CType(formatter.Deserialize(readFile), SortedList)

Dim aPerson As Person
Dim dt As Date
For Each dt In sl.Keys
aPerson = Ctype(sl.Item(dt), Person)
MessageBox.Show(aPerson.Name, aPerson.BirthDate.ToString)
Next

John

On Thu, 24 Mar 2005 00:58:22 -0800, "Michael Rich"
<mr***@michaelrich.com> wrote:
Can anyone point me to a collection class that has
serialization/deserialization with it - preferably in XML.

I know this can't be done with a collection that inherits from
CollectionBase, but I'm hoping someone has another collection class out
there.

Thanks;
Michael


Nov 21 '05 #4

P: n/a
It is serializable and marked as such; however I am having trouble
serializing it using custom serialization because I can't call
mybase.GetObjectData for it.
"Kerry Moorman" <Ke**********@discussions.microsoft.com> wrote in message
news:3D**********************************@microsof t.com...
Michael,

Both arraylist and hashtable can be serialized with a binaryformatter. I
think that arraylist can also be serialized as xml.

I'm surprised that collectionbase is not serializable. Are you sure about
that?

Kerry Moorman
"Michael Rich" wrote:
Can anyone point me to a collection class that has
serialization/deserialization with it - preferably in XML.

I know this can't be done with a collection that inherits from
CollectionBase, but I'm hoping someone has another collection class out
there.

Thanks;
Michael

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.