Serializing a generics SortedList

  • Thread starter Thread starter greg.merideth
  • Start date Start date
G

greg.merideth

Is it possible to serialize SortedList<T,V> or do I need to come up
with my own method to get the data into and out the list? I'm pretty
sure I know that it's "no" I'm just curious if there are any tricks
around.

Here's the error I get when I attempt to serialize a SortedList<T,V>

Unhandled Exception: System.NotSupportedException: The type
System.Collections.S
ortedList is not supported because it implements IDictionary.
 
I should have mentioned that I'm trying to serialize the SortedList
using XmlSerialize not a binaryformatter.
 
After finding the article on msdn I realize you can't serialize to XML
anything with IDictionary unless you implement your own IXmlSerializer
and I'm just not in the mood, I found a way to do it by copying my
SortedList<T,V> to a List<T> and damm if that didn't do the trick.

I'd still like to know why List<T> can be serialied but SortedList<T,V>
can't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top