如何将XML序列化字典 [英] How to XML-serialize a dictionary
本文介绍了如何将XML序列化字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经能够序列化一个IEnumerable是这样的:
I have been able to serialize an IEnumerable this way:
[XmlArray("TRANSACTIONS")]
[XmlArrayItem("TRANSACTION", typeof(Record))]
public IEnumerable<BudgetRecord> Records
{
get
{
foreach(Record br in _budget)
{
yield return br;
}
}
}
不过,我意识到,我现在需要一个包含集合词典词典&LT;字符串,RecordCollection&GT;
(RecordCollection实现IEnumerable)
However, I realised that now I need a dictionary containing a collection Dictionary<string, RecordCollection>
(RecordCollection implements IEnumerable).
我怎样才能做到这一点?
How can I achieve that?
推荐答案
看看下面的博客文章
- <打击> <一个href="http://blogs.msdn.com/b/psheill/archive/2005/04/09/406823.aspx">http://blogs.msdn.com/b/psheill/archive/2005/04/09/406823.aspx
- <一个href="http://web.archive.org/web/20100703052446/http://blogs.msdn.com/b/psheill/archive/2005/04/09/406823.aspx">http://web.archive.org/web/20100703052446/http://blogs.msdn.com/b/psheill/archive/2005/04/09/406823.aspx
和这一个(不是英文,而是code是有益的)
and this one (not in english, but the code is useful)
- <一个href="http://huseyint.com/2007/12/xml-serializable-generic-dictionary-tipi/">http://huseyint.com/2007/12/xml-serializable-generic-dictionary-tipi/
这篇关于如何将XML序列化字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文