If there are 2 interface IParentInterface &
IChildInterface as follows.
interface IParentInterface
{
void InterfaceMethod();
}
interface IChildInterface : IParentInterface
{
void InterfaceMethod();
}
Both the interface contains method with same name
InterfaceMethod().
How InterfaceMethod() will be handled in IChildInterface as
its deriving IParentInterface
Answers were Sorted based on User's Feedback
Answer / sagar
using explicit type casting this scenario is possible.
interface IParentInterface
{
void InterfaceMethod();
}
interface IChildInterface : IParentInterface
{
void InterfaceMethod();
}
class Parent : IChildInterface
{
void IParentInterface.InterfaceMethod()
{
Console.WriteLine("Parent Interface");
}
void IChildInterface.InterfaceMethod()
{
Console.WriteLine("Child Interface");
}
static void Main()
{
Parent p = new Parent();
IParentInterface i1 = p;
IChildInterface i2 = p;
i1.InterfaceMethod();
i2.InterfaceMethod();
Console.ReadLine();
}
}
| Is This Answer Correct ? | 14 Yes | 0 No |
Answer / vijay
In this scenario,
Whenever the child interface is called, by default
InterfaceMethod() of childe interface is gets called.
| Is This Answer Correct ? | 3 Yes | 2 No |
Answer / anurag
use
void IChildInterface.InterfaceMethod(){}
don't use access modifier with explicit method.
| Is This Answer Correct ? | 2 Yes | 4 No |
Which of these statements correctly declares a two-dimensional array in c#?
How do you inherit a class into other class in c#?
What is parameters in c#?
What is type system in c#?
What the different phase/steps of acquiring a proxy object in webservice?
Explain About friend and Protected friend
what is the default access for a class
Can you use foreach iteration on arrays in c#?
What is the difference between class and namespace?
What is the difference between internal and private in c#?
What is asp net c#?
If we inherit a class do the private variables also get inherited ?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)