1

I have a situation where in I cant use a Dictionary for name value collection of strings. My name value pair contains duplicate keys, because I need to support a legacy system. So please don't ask me to stop supporting duplicate keys. I tried to use NameValueCollection but this cannot be used with DataContractSerializer as it throws exception. Refer to the question for the error details.

Can anybody suggest alternative for this NameValueCollection type so that I can store key value pairs (only strings)?

4

1 回答 1

4

You could translate the name-value pairs into a List<Tuple<string, string>>, which according to this question is serializable.

Of course, you lose protection against duplicates, so you should only use this to get it across the wire.

于 2012-05-29T08:06:43.057 回答