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
Which are the loop types available in c#?
what class is underneath the sortedlist class?
What is namespace in oop?
What is a function c#?
Can you have an array of arrays?
What does mean before a string in c#?
Is type nullable c#?
What is overriding in c#?
Is stringbuilder faster than string concatenation c#?
What is get set in c#?
Explain about Error handling and how this is done
How long can a string be c#?
Are private members inherited in c#?
What is data hiding in c#?
What is xml comments in c#?