Can I specify a meaningful name for an anonymous class in C#?

Prashant Cholachagudda picture Prashant Cholachagudda · Apr 27, 2009 · Viewed 45k times · Source

We all know that when we create an anonymous class like this:

var Employee = new { ID = 5, Name= "Prashant" };

...at run time it will be of type:

<>f__AnonymousType0<int,string>

Is there any way to specify a meaningful name to such classes?

Answer

Chad Grant picture Chad Grant · Apr 27, 2009
public class Employee {}