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 an int be negative c#?
What is platform independence"?
Is int a struct in c#?
What does a constructor do c#?
What is string empty?
What is expression tree in c#?
What is the diff between System.String and System.Text.StringBuilder classes?
What is the size of a decimal?
What does mean before a string in c#?
Can we assign null value to integer?
How do I link two windows forms in c#?
Can we inherit a class with private constructor in c#?
What is asp net c# corner?
What is a collection class in c#?
What is callback function in c#?