SHARE
TWEET

Recursive type constraint error

mylesmcdonnell Jan 6th, 2012 18 Never
  1. public class Entity<T> { }
  2.  
  3. public class MyEntity : Entity<object> { }
  4.  
  5. public class Service<T> where T : Entity<T> { }
  6.  
  7. public class Test
  8. {
  9.    private Service<MyEntity> _service; //Not possible because MyEntity has to be convertible to Entity<MyEntity>
  10. }
RAW Paste Data
Top