I need an XML-serializable dictionary. Actually, I now have two quite different programs that need one. I was rather surprised to see that .NET doesn’t have one.
Can someone enlighten me, given how dependent various .NET features are on XML serialization, why there isn’t an XML-serializable dictionary?
The thing about XML Serialization is that it’s not just about creating a stream of bytes. It’s also about creating an XML Schema that this stream of bytes would validate against. There’s no good way in XML Schema to represent a dictionary. The best you could do is to show that there’s a unique key.
You can always create your own wrapper, for instance One Way to Serialize Dictionaries.