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 {       ...

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD