Is there any way to restrict a generic type parameter to an anonymous type?
Is there any way to restrict a generic type parameter开发者_如何学Go 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.
精彩评论