Click here to Skip to main content
11,711,750 members (78,860 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
i have an interface .details are given below

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 7-Mar-12 0:04am
Edited 7-Mar-12 0:26am
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

class myclass:myinterface
{
    void getmethods()
    {
        response.write("get method called");
    }
 
    void  interfacemethod() {}
 
    void methodtoimpliment() {}
        
}
  Permalink  
v2
Comments
chinta123 at 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 at 7-Mar-12 6:35am
   
Not possible.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

AFAIK it is not possible.
You have to implement all methods of interface.
Everything or Nothing.


What you are saying is not possible.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Nope: a consumer of the interface may safely assume it may call all the methods.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

no you have to split it in two interfaces.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

.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..
  Permalink  
v2
Comments
Marcus Kramer at 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)

  Print Answers RSS
0 CHill60 280
1 Sergey Alexandrovich Kryukov 264
2 OriginalGriff 170
3 Andy Lanng 160
4 Richard MacCutchan 130
0 CHill60 280
1 Sergey Alexandrovich Kryukov 125
2 Andy Lanng 120
3 Abhinav S 95
4 Maciej Los 95


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100