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
Is c# code is managed or unmanaged code?
Is dictionary a collection?
Define a class and an object?
Is it possible to have different access modifiers on the get/set methods of a property?
Is datetime a value type in c#?
Explain the difference between arraylist and array and in c#?
What is c# windows form application?
What do you mean by thread safe in c#?
What is the difference between abstract class and interface in c#?
What is an int c#?
Can abstract class be sealed in c#?
Can you declare struct members as protected?
When To use HashTable In C#
Explain anonymous type in c#?
Why dependency injection is used in c#?