Prakash Tripathi

Prakash Tripathi

  • 25
  • 43.8k
  • 6.2m

Regarding explicit interface implementation

Apr 22 2015 3:17 AM

Hello Folks,

I was exploring the explicit interface implementation and got a question.
 
In the example below  public void ITest.TestMethod() gives error however void ITest.TestMethod() works.
May I know the reason? 
 
 interface ITest

{

void TestMethod();

}

 
class TestClass: ITest

{

//public void ITest.TestMethod() //Error The modifier 'public' is not valid for this item

 void ITest.TestMethod() //Works

{

Console.WriteLine("Explicit Interface Implementation");

}

}

 

Answers (3)