Which method will be called from the following code? (or) Explain Polymorphism with New Modifier

Thursday, July 9, 2009


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

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

return "base";
}
}
class DerivedClass : BaseClass
{
public new 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:

base


www.codecollege.NET

0 comments

Post a Comment

LinkWithin

Blog Widget by LinkWithin

Recommended Books