المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problem with Interface?



C# Programming
02-08-2010, 12:00 AM
Hello,
I wanna know If i declare function with same name, in interface and base class. and inherit this with Drived class. and call this function with drived obj.What Does it throws an error or not?

If not how its differentiates which function to call?

and how to call both the function?

EG:

Public Interface Iface
{
Void Display();
}

Public Class Base
{
Public Void Display()
{
Console.Readline("This is Base Class Method");
}
}

Public Class Derived : Base, Iface
{
Public Void Display()
{
Console.Readline("This is Interface Method");
}
}

Main()
{
Derived Dobj = new Derived();
Dobj.Display();
Console.Readline();
}


Which function is called?