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 / bhagyashri
C# Support Inheritance & in C# multiple inheritance is
achieved by using interface.multiple interface means one
class can derived by two class..and class can be derived
only one class but more than one interface.so for multiple
inheritance we use interface
for eg:
interface i1
{
public void Method1();
}
interface i2
{
public void Method2();
}
class A:i1,i2
{
public void Method1()
{
Console.WriteLine("Hi");
}
public void Method2()
{
Console.WriteLine("Hello");
}
}
class main()
{
public static void Main()
{
A a=new A();
a.Method1();
a.Method2();
Console.ReadLine();
}
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is msil in c#?
What is default c#?
What is the main method?
What is continue in c#?
Why do we use static class in c#?
What is the benefit of dependency injection c#?
List some of the common data providers for ado.net framework?
What is difference between float and decimal?
What is the use of flag in c#?
Are constructors inherited c#?
What is part of a method signature in c#?
What is dictionary class in c#?
Explain states of a thread in c#?
What is deadlock in c#?
In .NET which is the smallest unit of execution?