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
Can we create extension method for interface?
What is the .NET collection class that allows an element to be accessed using a unique key?
Define multicast c# delegate?
What is function c#?
What is difference between class and abstract class in c#?
In which format you can pass the value in the sleep function?
Should I make my destructor virtual?
What is an array class?
Explain about multithreading?
What is difference between const and static in c#?
Explain About .Net remoting
Can main method be final?
What is the use of protected in c#?
In the page load event I assigned dropdownlist’s datasource property to a valid list. On the submit button click.. The same datasource property is coming as null. Why?
Can an abstract class inherit from another abstract class c#?