Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have an interface .details are given below

C#
Interface myinterface
{
   void getmethods();
   void  interfacemethod();
   void methodtoimpliment();
}

class myclass:myinterface
{
    getmethods()
    {
        response.write("get method called");
    }
}
class Implement:myinterface
{
   interfacemethod()
    {
   response.write("interface method called:");
    }
methodtoimplement()
  {
      response.write("implement method called:");
  }
}


is it possible or not??
Posted
Updated 7-Mar-12 0:26am
v4

No. You MUST implement the methods, but they don't have to do anything:

C#
class myclass:myinterface
{
    void getmethods()
    {
        response.write("get method called");
    }

    void  interfacemethod() {}

    void methodtoimpliment() {}
        
}
 
Share this answer
 
v2
Comments
chinta123 7-Mar-12 6:28am    
thank you.but i have just change my question .can you please tell me is it possible or not??
nagendrathecoder 7-Mar-12 6:35am    
Not possible.
AFAIK it is not possible.
You have to implement all methods of interface.
Everything or Nothing.


What you are saying is not possible.
 
Share this answer
 
v2
No, you must implement all the methods of an interface

An interface gaurantees a 'contract' - if a class implements an interface then you know that the methods on that class are available.
 
Share this answer
 
Nope: a consumer of the interface may safely assume it may call all the methods.
 
Share this answer
 
v2
no you have to split it in two interfaces.
 
Share this answer
 
.NET does not support multiple inheritances directly because in .NET, a class cannot inherit from more than one class. .NET supports multiple inheritances through interfaces.
for more..
 
Share this answer
 
v2
Comments
fjdiewornncalwe 25-Feb-13 13:59pm    
It is not acceptable to use this site as a traffic driver for your own site. Account and posts have been flagged.

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