1)What is Explicit Interface Implementation in C#?
OR
What is the advantage of Explicit Interface Implementation in C#?
OR
Example on Explicit Interface Implementation in C#?
OR
How to implement multiple inheritance in C#?
Scenario like implement the method from two interfaces which are having the same name and signature.
We can exhibit more abstraction using this but is not suggested.
using this we can implement multiple inheritance
public interface IStduent
{
void GetData();
//void PutData();
}
public interface ITeacher
{
void GetData();
}
public class Program : IStduent,ITeacher
{
public string Message
{
get;
set;
}
void IStduent.GetData()
{
Console.WriteLine("I am from IStudent");
}
void ITeacher.GetData()
{
Console.WriteLine("I am from ITeacher");
}
static void Main(string[] args)
{
Program pObj = new Program();
IStduent isobj = (IStduent) pObj;
isobj.GetData();
ITeacher itobj = (ITeacher)pObj;
itobj.GetData();
Console.ReadLine();
}
}
Output:
I am from ITeacher
Thanks for visiting this blog. How is the content?. Your comment is great gift to my work. Cheers.
No comments:
Post a Comment