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 ?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With