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

How is a string immutable?

684


Can datetime be null c#?

643


Is and as keyword in c# net?

728


List down the reason behind the usage of c# language.

870


Illustrate serialization?

699


What is event sourcing in c#?

702


What is windows application in c#?

656


What is difference between value and reference types in C#.NET

735


What does mean c#?

692


Can I get the name of a type at runtime?

743


Why do we use stringbuilder in c#?

698


Why is it important to override gethashcode when equals method is overridden?

750


Write a program in C# for checking a given number is PRIME or not.

840


Why do canadians say zed?

755


What all details the assembly manifest will contain?

621