I want to serialize a class which uses an anonymous function in its implementation. The compiler is generating an inner class to implement the anonymous function. The serializer fails with the error: "MyClass+<>c__DisplayClass2 is inaccessible due to its protection level. Only public types can be processed."
public class MyClass {
public doIt() {
int objective = 0;
return List<int> () { 1 }.Any(i => i == objective);
}
}
new XmlSerializer(typeof(MyClass)).Serialize(writer, myClass);
How do I serialize this class? Thanks.