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
What is dynamic dispatch?
What is datasource c#?
Why delegates are safe in c#?
Can you mark static constructor with access modifiers?
What is dataset and dataadapter in c#?
What are the 2 broad classifications of data types available in c#?
How can we sort the elements of the array in descending order?
What is the use of properties window?
How to override a function in c#?
What are the advantages of using c#?
Why do we need to call CG.SupressFinalize?
Can we override interface methods in c#?
What is null propagation c#?
How do I develop c# apps?
Does c# support a variable number of arguments?