compile time error because Myclass is not implementing the method of IMyInterface . interface implented method must be public.
Try this type...... public interface IMyInterface { void fun1();void fun2();}class MyClass : IMyInterface {void IMyInterface.fun1(){ }void IMyInterface.fun2(){}}
Compile time error. In derived class, implemented methods should be declared as public.interface IMyInterface { void fun1(); void fun2(); } class MyClass : IMyInterface { public void fun1() {} public void fun2(){ }}
It will give compile time error be as MyClass should implement all interface member. Because all interface function definition should be public in class.
above code will give the error please tyr below:-interface IMyInterface{void fun1();void fun2();}class MyClass : IMyInterface{public void fun1(){}public void fun2(){}}
For more information please read this link : https://msdn.microsoft.com/en-us/library/ms173157.aspx
interface IMyInterface {void fun1();void fun2(); }class Class1 : IMyInterface {public void fun1() { } public void fun2() { } }
MyClass access modifiers functions are private now. So you cont build this one.You will get bellow error message:"Error 1 'ConsoleApplication1.Program.MyClass' does not implement interface member 'ConsoleApplication1.Program.IMyInterface.fun2()'. 'ConsoleApplication1.Program.MyClass.fun2()' cannot implement an interface member because it is not public. D:\Work\Test\ConsoleApplication1\ConsoleApplication1\Program.cs 18 15 ConsoleApplication1 "http://asp-net-corner.blogspot.in/
Hi Arup,Thanks for reply. As you said all members of interface are by default public that is correct. The members of class, MyClass is private, since access modifiers are not mention here, after implementing interface. So it will not compile. Plz let me know if you have any dought.
It will not show any error during compile time. please check this code, all members inside interface are public bydefault
Ans: It will not compile because access modifier of fun1() and fun2() are private. It should be public.