Q:

What is the "+<>c__DisplayClassX" type suffix where X is a number?

I have an exception thrown by a WPF application. The message is:
Type 'MyNamespacesPath.AType+<>c__DisplayClass5' in Assembly... is not marked as serializable

The problem is that the type cannot be serialized.
But that type is autogenerated, maybe an anonymous method or expression tree.
Anyone knows the exact origin of these kinds of types to know where to find the bug?

A:

Types with that kind of name are generated when you write an anonymous method (using the delegate syntax or a lambda expression) that captures a local variable. The role of these types is to hold the values of the captured variables
Note that other kind of generated types have different names: 

anonymous types have names like <>f__AnonymousType0<<a>j__TPar, <b>j__TPar> (generated by new { a = 1, b = "2" }).
iterators also generate new types like <ZipIterator>d__0<TFirst, TSecond, TResult> (notice the name of the iterator method between the angled brackets)

As far as I know, there is no documented rule for the naming of generated types, so you shouldn't rely on these observations in your code. I'm just mentioning them for completeness.

