Factory Pattern

Your Ad Here

What is a Factory Pattern :Factory Pattern creates an instance of several derived classes.

using System;
using System.Collections.Generic;
using System.Text;

namespace FactoryPattern
interface IBase
void DoIt();
class Derived1:IBase
public void DoIt()
Console.WriteLine("Derived1 Method is called");
class Derived2:IBase
public void DoIt()
Console.WriteLine("Derived2 Method is called");
class Factory
public IBase getObject(int type)
IBase objIBase = null;
switch (type)
case 1:
objIBase = new Derived1();
case 2:
objIBase = new Derived2();
return objIBase;
class Program
static void Main(string[] args)
Factory objFactory = new Factory();
IBase objIbase = objFactory.getObject(1);



Posted in Labels: , kick it on DotNetKicks.com |


  1. Anonymous Says:

    Best Casinos tyuueooru
    Casino Money
    If you end up choosing a not-so-good online casino website, you'll never enjoy the actual pleasure arriving with online gambling.
    [url=http://www.nhgaa.org/]Online Casinos Free[/url]
    000 free with your first 20 deposits!
    The risks arriving with the gambling has decreased to a great extent after the arrival of free online casino.
    http://www.nhgaa.org/ - Free Casino
    So, it is vital to be able to find a right online casino website for you if you don't want your online gambling experience to be annoying and regretting.

  2. Anonymous Says:

    Great Ρ•ite you have got here.. It's difficult to find quality writing like yours nowadays. I honestly appreciate individuals like you! Take care!!

    Also visit my web blog: Instant online Payday Loans
    Also see my page: Payday Loans

  3. Anonymous Says:

    Ahaa, its good discussion on the topic of this piece of writing at
    this place at this weblog, I have read all that, so now me
    also commenting at this place.
    Take a look at my blog post - slots online game

  4. Anonymous Says:

    Hello mates, good post and good arguments commented at this place, I am in fact enjoying by these.
    Take a look at my page play penny slots online

  5. Anonymous Says:

    I have been browsing online greater than three hours as of late, but I by no means discovered any attention-grabbing article like
    yours. It's pretty value enough for me. Personally, if all web owners and bloggers made excellent content material as you did, the web shall be much more useful than ever before.
    Also visit my homepage :: lobstermania roulette

  6. Anonymous Says:

    Having read this I believed it was rather
    informative. I appreciate you spending some time and effort to put this article together.
    I once again find myself spending a lot of time both reading
    and commenting. But so what, it was still worthwhile!
    Here is my blog :: easy way to make money online

  7. Anonymous Says:

    Thank you, I have recently been looking for info approximately this subject for a while and yours is the best I've came upon till now. But, what concerning the bottom line? Are you sure in regards to the source?
    My blog post :: online slot machines with bonuses

  8. Anonymous Says:

    Asking questions are in fact good thing if you are not understanding something totally, however this paragraph
    gives nice understanding yet.

    Here is my weblog - forex binary options