can you overload a method of class A in Class B if it is
derived class of A?If it is yes tell me how is it possible?

Answer Posted / lalit pradhan

namespace Test
{
class Program
{
static void Main(string[] args)
{
A a = new A();
a.Method();

B b = new B();
b.Method("From B");

Console.ReadKey();
}
}

class A
{
public void Method()
{
Console.WriteLine("From A");
}
}

class B : A
{
public void Method(string s)
{
Console.WriteLine(s);
}
}
}

Is This Answer Correct ?    15 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is delegates and events?

476


Which programming language is best for desktop applications?

461


Define strong name in c#?

523


How many bytes is a char c#?

487


Why we use get set in c#?

503






Enlist some of the properties of a thread class?

513


What is difference between code access and role based security?

510


What is sorting in c#?

521


What are the return types in c#?

497


Is python easier than c#?

497


What is the difference between == and object.equals?

509


How Global.asax is used ?

615


Is c# good for games?

480


When To use HashTable In C#

551


What is a variable in c#?

475