Is there any way to restrict a generic type parameter to an anonymous type in C# 4.0? Or is where T: class
the closest I will come ?
Asked
Active
Viewed 1,128 times
8

smartcaveman
- 41,281
- 29
- 127
- 212
1 Answers
7
No, there are no such constraints in C#. You could add an execution-time check to validate that the type has the characteristics of an anonymous type though.