This post is in continuation of this one.
I am trying to understand if I am the only one who misses and needs the ability of a .NET generic type to inherit one of it
The good reason to make it possible to inherit from a type parameter is because of the following situation:
I have would like to have an abstract ViewModel class which inherits from an Entity class and has some additional properties and methods.
public abstract class ViewModel : TEntity, IViewModel
where TEntity : class, IEntity, new() {
public void SomeMethod() {
}
}
Then i could make a specific ViewModel
public class EmployeeViewModel : ViewModel {
}
Nice ! it inherits all the fields of the entity and has the standard properties and methods of the abstract viewmodel ! ..
This sadly cannot be done now.