Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
When would one use Generics over Inheritance?

What I have tried:

When would one use Generics over Inheritance?
Posted
Updated 19-Jun-22 18:33pm
Comments
George Swan 20-Jun-22 3:47am    
Should the question be, when to use inheritance rather than an interface when designing a class?
CPallini 20-Jun-22 4:23am    
Use The Force, then Generics, then Inheritance.
PIEBALDconsult 20-Jun-22 23:32pm    
Always.

1 solution

You don't: the two concepts are unrelated and are not interchangeable as a result.
Inheritance | Microsoft Docs[^] and Generic classes and methods | Microsoft Docs[^]

While generics can be used in conjunction with inheritance, they aren't a replacement for each other!
 
Share this answer
 
Comments
CPallini 20-Jun-22 4:22am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900