开发者

"Ambiguous Constructor Reference" XmlSerializer

I am trying to seri开发者_如何学编程alize a List<MyObject>. When I create my XmlSerializer as such:

XmlSerializer xmlSerializer = new XmlSerializer(List<MyObject>);

I get the following error: Ambiguous Constructor Reference

How can I fix this so I can serialize and deserialize my list?


XmlSerializer xmlSerializer = new XmlSerializer(typeof(List<MyObject>));

or

XmlSerializer xmlSerializer = new XmlSerializer(myList.GetType());

You are trying use this constructor, but you're not passing in a Type object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜