views:

31

answers:

1

I am trying to serialize 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?

+1  A: 
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.

Yuriy Faktorovich
Thanks. Missed that!
Vaccano