Click here to Skip to main content
15,892,298 members
Home / Discussions / C#
   

C#

 
GeneralRe: Polymorphism through Inheritance Pin
Ankit Rajput21-Apr-11 1:08
Ankit Rajput21-Apr-11 1:08 
GeneralRe: Polymorphism through Inheritance Pin
Pete O'Hanlon21-Apr-11 1:11
mvePete O'Hanlon21-Apr-11 1:11 
GeneralRe: Polymorphism through Inheritance Pin
Lutosław21-Apr-11 3:13
Lutosław21-Apr-11 3:13 
GeneralRe: Polymorphism through Inheritance Pin
#realJSOP21-Apr-11 4:42
mve#realJSOP21-Apr-11 4:42 
AnswerRe: Polymorphism through Inheritance Pin
BobJanova21-Apr-11 1:09
BobJanova21-Apr-11 1:09 
AnswerRe: Polymorphism through Inheritance Pin
Wayne Gaylard21-Apr-11 1:22
professionalWayne Gaylard21-Apr-11 1:22 
GeneralRe: Polymorphism through Inheritance Pin
Ankit Rajput21-Apr-11 5:50
Ankit Rajput21-Apr-11 5:50 
GeneralRe: Polymorphism through Inheritance Pin
AspDotNetDev21-Apr-11 7:07
protectorAspDotNetDev21-Apr-11 7:07 
Ankit Rajput wrote:
there is no way to call parent class function from the object of Child


Actually...

C#
public class Animal
{
    public virtual void MakeNoise()
    {
        MessageBox.Show("Blarg!");
    }
}

public class Dog : Animal
{
    public override void MakeNoise()
    {
        base.MakeNoise();
        MessageBox.Show("Bark!");
    }
}

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        (new Dog()).MakeNoise();
    }
}


And just because you are "obsoleting" one of the functions does not mean it is not polymorphism. There are other behaviors and properties that probably got inherited. Not to mention you still get the ability to "morph":
C#
var animals = new List<Animal>();
animals.Add(new Dog());
animals.ForEach((animal) => animal.MakeNoise());

Chris Maunder wrote:
Fixign now.
But who's fixing the fixign?

AnswerRe: Polymorphism through Inheritance Pin
Keith Barrow21-Apr-11 1:48
professionalKeith Barrow21-Apr-11 1:48 
AnswerRe: Polymorphism through Inheritance Pin
Prasanta_Prince21-Apr-11 2:20
Prasanta_Prince21-Apr-11 2:20 
GeneralRe: Polymorphism through Inheritance Pin
Ankit Rajput21-Apr-11 5:58
Ankit Rajput21-Apr-11 5:58 
QuestionAjaxupload Pin
dbongs20-Apr-11 23:47
dbongs20-Apr-11 23:47 
AnswerRe: Ajaxupload Pin
Pete O'Hanlon21-Apr-11 0:03
mvePete O'Hanlon21-Apr-11 0:03 
GeneralRe: Ajaxupload Pin
dbongs21-Apr-11 0:17
dbongs21-Apr-11 0:17 
GeneralRe: Ajaxupload Pin
Pete O'Hanlon21-Apr-11 0:42
mvePete O'Hanlon21-Apr-11 0:42 
GeneralRe: Ajaxupload Pin
Mycroft Holmes21-Apr-11 0:56
professionalMycroft Holmes21-Apr-11 0:56 
GeneralRe: Ajaxupload Pin
BobJanova21-Apr-11 1:07
BobJanova21-Apr-11 1:07 
GeneralRe: Ajaxupload Pin
#realJSOP21-Apr-11 4:50
mve#realJSOP21-Apr-11 4:50 
GeneralRe: Ajaxupload Pin
dbongs21-Apr-11 2:00
dbongs21-Apr-11 2:00 
GeneralRe: Ajaxupload Pin
Pete O'Hanlon22-Apr-11 9:50
mvePete O'Hanlon22-Apr-11 9:50 
GeneralRe: Ajaxupload Pin
#realJSOP21-Apr-11 4:49
mve#realJSOP21-Apr-11 4:49 
GeneralRe: Ajaxupload Pin
Keith Barrow21-Apr-11 7:10
professionalKeith Barrow21-Apr-11 7:10 
AnswerRe: Ajaxupload Pin
BobJanova21-Apr-11 0:26
BobJanova21-Apr-11 0:26 
GeneralRe: Ajaxupload Pin
dbongs21-Apr-11 0:32
dbongs21-Apr-11 0:32 
Questiontry {} catch {} not working Pin
ShadowUz20-Apr-11 22:59
ShadowUz20-Apr-11 22:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.