Generics, a simple usage for OOP
Posted by: Patrik Löwendahls shout,
on 13 Jan 2006 |
View original | Bookmarked: 0 time(s)
A simple example where I find generics very useful. Imagine the scenario where you have a abstract base class that defines a create method. The create method will be implemented by several sub classes and will return a single entity object. In C# 1.0 / 1.1 we had to rely on type casting to make this happen. Like so: public abstract class Entity { public int Id; } public abstract class Factory { ...