Click here to Skip to main content
15,886,806 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# very basic basic` PinPopular
Richard MacCutchan14-Apr-11 2:50
mveRichard MacCutchan14-Apr-11 2:50 
AnswerRe: C# very basic basic` Pin
PIEBALDconsult14-Apr-11 2:51
mvePIEBALDconsult14-Apr-11 2:51 
AnswerRe: C# very basic basic` Pin
V.14-Apr-11 4:06
professionalV.14-Apr-11 4:06 
AnswerRe: C# very basic basic` Pin
Luc Pattyn14-Apr-11 4:13
sitebuilderLuc Pattyn14-Apr-11 4:13 
AnswerRe: C# very basic basic` Pin
daveThawley14-Apr-11 11:53
daveThawley14-Apr-11 11:53 
QuestionWhich is more usefull Abstract Class or Interface and Why? Pin
Prasanta_Prince13-Apr-11 19:26
Prasanta_Prince13-Apr-11 19:26 
AnswerRe: Which is more usefull Abstract Class or Interface and Why? PinPopular
David198713-Apr-11 19:34
David198713-Apr-11 19:34 
AnswerRe: Which is more usefull Abstract Class or Interface and Why? Pin
BobJanova13-Apr-11 23:17
BobJanova13-Apr-11 23:17 
An abstract class is generally useful when you are providing a partially or almost functional class, but you require certain things to be overridden to make it fully functional. For example, although they didn't, it would have made sense for Microsoft to make UserControl abstract and make its OnPaint method abstract. Or in my game lobby[^], the BaseLobby is abstract to provide some reusable code to both client and server.

An interface is generally useful when you want otherwise not directly related classes (i.e. they are not part of the same inheritance tree within your code, e.g. two custom controls, or a 'view' in MVC parlance that displays to the screen and one which sends information down a network) to expose common functionality. An interface can be used to 'patch in' functionality into objects that already have an inheritance tree. For example the interface INotifyPropertyChanged – any type of object can be declared to be the source of notification events, without any reason to restrict it to one part of the inheritance branch.

The functionality you're trying to patch in is usually small, most interfaces will only be a few methods, though there are some dubious cases in the framework. (Why would you want to implement IList<T> from scratch, for example?) The downside of an interface is that you need to implement all the methods (and properties) yourself in each class that implements it, which is why they should be simple.

So the short answer is: both, depending on what you want to do.
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Anubhava Dimri14-Apr-11 1:39
Anubhava Dimri14-Apr-11 1:39 
AnswerRe: Which is more usefull Abstract Class or Interface and Why? [modified] Pin
Pete O'Hanlon14-Apr-11 1:46
mvePete O'Hanlon14-Apr-11 1:46 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
David198714-Apr-11 2:12
David198714-Apr-11 2:12 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Pete O'Hanlon14-Apr-11 2:19
mvePete O'Hanlon14-Apr-11 2:19 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Pete O'Hanlon14-Apr-11 2:24
mvePete O'Hanlon14-Apr-11 2:24 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
David198714-Apr-11 2:30
David198714-Apr-11 2:30 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Pete O'Hanlon14-Apr-11 2:42
mvePete O'Hanlon14-Apr-11 2:42 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Wayne Gaylard14-Apr-11 2:42
professionalWayne Gaylard14-Apr-11 2:42 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Pete O'Hanlon14-Apr-11 2:45
mvePete O'Hanlon14-Apr-11 2:45 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Prasanta_Prince15-Apr-11 6:34
Prasanta_Prince15-Apr-11 6:34 
AnswerRe: Which is more usefull Abstract Class or Interface and Why? Pin
#realJSOP14-Apr-11 2:01
mve#realJSOP14-Apr-11 2:01 
AnswerRe: Which is more usefull Abstract Class or Interface and Why? Pin
PIEBALDconsult14-Apr-11 2:57
mvePIEBALDconsult14-Apr-11 2:57 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Luc Pattyn14-Apr-11 4:15
sitebuilderLuc Pattyn14-Apr-11 4:15 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Keith Barrow14-Apr-11 4:31
professionalKeith Barrow14-Apr-11 4:31 
AnswerRe: Which is more usefull Abstract Class or Interface and Why? Pin
Luc Pattyn14-Apr-11 4:17
sitebuilderLuc Pattyn14-Apr-11 4:17 
AnswerRe: Which is more usefull Abstract Class or Interface and Why? Pin
Keith Barrow14-Apr-11 4:29
professionalKeith Barrow14-Apr-11 4:29 
GeneralRe: Which is more usefull Abstract Class or Interface and Why? Pin
Pete O'Hanlon14-Apr-11 5:28
mvePete O'Hanlon14-Apr-11 5:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.