Which method will be called from the following code? (or) Explain Polymorphism with override Modifier in c#.

Thursday, July 9, 2009


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

namespace OOPs21
{
class BaseClass
{
public virtual string ShowMe()
{

return "base";
}
}
class DerivedClass : BaseClass
{
public override string ShowMe()
{

return "derive";
}

public static void CallShowME(BaseClass objBC)
{
Console.Write(objBC.ShowMe());
}


public static void Main()
{
DerivedClass vardc = new DerivedClass();
CallShowME(vardc);
Console.Read();
}

}
}




Answer:

derive


www.codecollege.NET

0 comments

Post a Comment

LinkWithin

Blog Widget by LinkWithin

Recommended Books