http://www.sqlservercentral.com/articles/Stairway+Series/87629/
Implement Factory pattern using generics public interface IDoWork { string DoWork(); } Declare an Interface first by abstracting the common functionality Here I am taking the example of DoWork public class Manager : IDoWork { public string DoWork() { return "Manager Manages School" ; } } Implement the IDoWork in concrete classes as shown public class Teacher : IDoWork { public string DoWork() { return "Teacher teaches student in school" ; } } public class Student : IDoWork { public string DoWork() { return "Study in school" ; } } This class will actually create an instance of the concrete class so that you can work on that object further public class FactoryDemo { public T Create
Comments
Post a Comment