开发者

"Ambiguous Constructor Reference" XmlSerializer

开发者 https://www.devze.com 2022-12-16 01:05 出处:网络
I am trying to seri开发者_如何学编程alize a List<MyObject>.When I create my XmlSerializer as such:

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

精彩评论

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