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

Similar Posts

  • Service Bus in Azure more
  • In Love With Complexity more
  • Isolated Storage Might Be Easier Than You Think more
  • World's Simplest Recursive CTE? more
  • XML Schema Facets more
  • ASP.NET: Implementing designer for a templated server control more
  • How bad is string concat really more
  • BizTalk messages based on .NET types instead of Xsd schemas more

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