Example #1
0
    static void Main(string[] args)
    {
        //here's what u asking about
        FamilyMembers myBrother = new MyBrother();     //MyBrother is a family member, the system now will choose the GetData() method from the child class MyBrother

        myBrother.GetData();
        Console.ReadLine();
    }
    static void Main(string[] args)
    {
        //now let's try to call the the methods and spawn the child classes :)
        //spawn the child class (MyBrother) that inherits from the Family interface
        //this is the answer of ur question
        IFamily myBrother = new MyBrother();     // the constructor will auto-set the data for me so i don't need to set them

        //printing the dude
        myBrother.PrintData();
        Console.ReadLine();
    }