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

What is difference between float and integer?

559


Where test director stores its data ? Database ,Local file etc...? I need to read this data from Visual Studio 2005 c# client. Regards

1475


What is multithreading with .net?

538


Why abstract class can not be instantiated?

452


What is state c#?

439






Why can't we use a static class instead of singleton?

451


Why we need get set property in c#?

542


Can a abstract class have a constructor?

467


Where do I put dll files?

574


Different between method overriding and method overloading?

488


Explain the steps to create satellite assembly?

487


How will you allow a class to be inherited, but prevent the method from being over-ridden?

525


What is console writeline in c#?

471


What exactly is serverless?

425


Why should you override the tostring() method?

597