How to have public methods implemented from interface?

First method is explicit implementation. This allows you to implement interface, without showing this method outside of your class. Also, you cant have visibility modifier on explicit implementation Second method is normal (implicit) implementation, where you implement interface AND create public method More : Implicit and Explicit Interface Implementations C#: Interfaces - Implicit and Explicit implementation For your second question : This is exacly what interface is.It only tells you, what method, properties or events are available on the object.

Not how they are implemented.

First method is explicit implementation. This allows you to implement interface, without showing this method outside of your class. Also, you cant have visibility modifier on explicit implementation.

Second method is normal (implicit) implementation, where you implement interface AND create public method. More : Implicit and Explicit Interface Implementations, C#: Interfaces - Implicit and Explicit implementation For your second question : This is exacly what interface is. It only tells you, what method, properties or events are available on the object.

Not how they are implemented.

I answer to your second question: yes, it's correct. Interface declare a sort of contract you must work with if you implement that interface. An interface simply (and only) declare what you MUST writein your classes if you implement those interfaces.

The first is called explicit implementation, it will work like this: interface ITest { void TestVoid(); } class A : ITest { public static void Main() { A a1 = new A(); ITest a2 = new A(); a1.TestVoid(); // won't work a2.TestVoid(); // will work } public void ITest.TestVoid() { Conole. WriteLine("Done"); } } Interface cannot ever contain implemenations, only signatures.

Thanks. And what if I implement the method with public modifier and omit the interface name (the second example in my sample)? It obviously works but I have no clue whether its OK.

– Miria Apr 17 at 12:39.

The second one is alright so you can use it.

You need to implement the interface like. Class A : ITest { }. You can implement ITests methods explicitly with ITest.

Prefix Or implicitly as public methods If they are explicit the the way to access them is as such. ITest a = new A(); Otherwise. A a = new A(); An interface never has an implementation, A class method always does unless it's marked as abstract - then the derived class has the implementatio n.

Edited and added, thanks. However indeed it does not solve the problem, I just forgot to write it. – Miria Apr 17 at 12:31.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions