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


Please Help Members By Posting Answers For Below Questions

How to prevent the error while updating ui control from another thread?

493


What are the two uses of a ‘using’ statement in c#?

471


How to use delegates with events?

540


What is literal in c#?

467


What is the difference between method overriding and method overloading?

473






How do you type a null character?

496


How big is an int16?

484


What is parallel foreach in c#?

532


Explain the difference between arraylist and array and in c#?

500


Explain the OOPS concept in C#?

576


What are Regex / regular expressions ?

576


What is a interface in c#?

467


If a method's return type is void, can you use a return keyword in the method?

532


I have 3 overloaded constructors in my class. In order to avoid making instance of the class do I need to make all constructors to private?

542


What is c# most used for?

557