C# Class Factories

Posted by Andy on Stack Overflow See other posts from Stack Overflow or by Andy
Published on 2011-03-14T22:11:46Z Indexed on 2011/03/15 0:10 UTC
Read the original article Hit count: 193

Filed under:
|

I have a class called Foo that has a function that looks like the following

List<Bar> LoadData();

Both Foo and Bar are in a library that I want to reuse in other projects. Now I am working on a new project and I want to subclass Bar. Let's call it NewBar.

What is a simple and flexible way to get Foo.LoadData to return a list of NewBar? I think that a factory is needed or perhaps just a delegate function. Can anyone provide an example?

Thanks, Andy

© Stack Overflow or respective owner

Related posts about c#

Related posts about design-patterns