8

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 ?

smartcaveman
  • 41,281
  • 29
  • 127
  • 212

1 Answers1

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.

Community
  • 1
  • 1
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194