Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi
how does one interface inherited itself from more than one interface?
please help me how to implement that how to call methods?(take a look below)

EXAMPLE:

C#
public interface IFirst { void oneMethod(); }
public interface ISecond { void oneMethod(); }
public class:IFirst,ISecond
{
  // I want implement those methods here.how is it? 
}
Posted
Updated 24-Aug-11 9:19am
v2
Comments
Sergey Alexandrovich Kryukov 24-Aug-11 17:36pm    
I hope you would not have a problem if not two methods with identical names and signatures. This is the root of your problem, not the mere fact of implementing two interfaces.
--SA

 
Share this answer
 
v2
Comments
Pradeep Kurmi 31-Jan-13 13:23pm    
I have also many doubt about interface...... please help
AspDotNetDev 31-Jan-13 14:26pm    
Post a new question and maybe somebody will answer it. You won't get an answer by posting a non-question to a comment in the answer for another person's question.
C#
public interface IFirst { void oneMethod(); }
public interface ISecond { void oneMethod(); }
public class:IFirst,ISecond
{
  // I want implement those methods here.how is it?
}



--answer
C#
public class myclass:IFirst,ISecond
{
  // I want implement those methods here.how is it?

public void IFirst.oneMethod
{
//do something
}
public void ISecond.oneMethod
{
// do something
}


//call the method like this

IFirst obj=new myclass();
ISecond obj1=new myclass();
obj.oneMethod();
obj1.oneMethod();


}
 
Share this answer
 
v2
Comments
Karthik_Mahalingam 2-Jan-14 4:41am    
4 ,Good,
whenever posting a solution.
add it inside code block
Vinay Jade 2-Jan-14 9:20am    
i have doubt here can we create object of an interface and if we can create object of interface then whats the use of inheriting
Karthik_Mahalingam 2-Jan-14 9:36am    
we cannot create directly.
by dependency injection, we can create like
InterfaceName obj = new ClassNameImplementingInterface();
Vinay Jade 2-Jan-14 9:41am    
ok i dont know that thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900