Interviews8 answers
What is explicit and implicit interface and in which condition we should use ?
8 Answers
When the Interface methods are publicly declared they are called Explicit interfaces; where as when the interface methods are declared privately, they are said to be implicit Interfaces
sanjib kotalPosted Jul 9, 2016, 4:42 AM EDT
https://msdn.microsoft.com/en-us/library/aa288461(v=vs.71).aspx
Rajesh SinghPosted Dec 4, 2015, 10:02 PM EST
Implementing interface members with interface name is called explicit interface where as without interface name is called implicit interface.
In common situation we use implicit interface. But when a class implement 2 or more interface having same method signature at that moment we use explicit interface.
Sujeet SumanPosted Jun 18, 2015, 1:21 AM EDT
When you implement the some member of interface in your class without specifying your interface name that is called implicit interface else if you implement the some member of interface in your class with their fully qualified path means interface name and method name with dot this is called explicit interface
Neeraj UpadhyayPosted May 26, 2015, 3:51 AM EDT
In Implicit interface we simply inherit the method of a Interface with out using interface name but when use a interface name before method name in abstract class then it is known as Explicit interface .
An Explicit interface we can not call method of a interface using class object ..
We should be create a instance of Interface that will hold a reference of class object
Pankaj Kumar ChoudharyPosted May 13, 2015, 8:46 PM EDT
Let's say your
one class -> implement two interface (I1 and I2 - having same method name A() )-> it can create conflicts with your requirements-> so to overcome this instead of implicit interface you use explicit interface.
For using explicit interface -> you need to add fully qualified method name with interface in your class.
For ex instead of using only A() you need to write I1.A() in your class
Madhuri MishraPosted May 1, 2015, 6:38 AM EDT
In simple words, When you implement the member of the interface in the class without specifying the interface name, then it's called as Implicit interface implementation.
On the other side, if you are creating the object of interface then calling it's method then it's explicit implementation.
Below is the simple example which explains the same.
interface ITest
{
void TestMethod();
}
class TestClass: ITest
{
public void TestMethod()
{
Console.WriteLine("Implicit Interface Implementation");
}
void ITest.TestMethod()
{
Console.WriteLine("Explicit Interface Implementation");
}
}
class Program
{
static void Main(string[] args)
{
TestClass obj = new TestClass();
obj.TestMethod(); //Way to call implicitely implemented method
ITest obj2 = new TestClass();
obj2.TestMethod();
Console.ReadLine();
}
}
Just to add the constraint with explicit implementation is that explicitly implemented member cannot be accessed through a class instance, but only through an instance of the interface. You can see the same in example above.
Prakash TripathiPosted Apr 21, 2015, 8:27 PM EDT
http://www.c-sharpcorner.com/UploadFile/8911c4/implicit-and-explicit-interface-examples/
Munesh SharmaPosted Apr 15, 2015, 10:55 PM EDT






