Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
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 
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 
This really smells like a homework question to me.

A way to think about it. An interface is a contract. It states that your class will have certain elements, but it puts no constraints on how they will be achieved. An abstract class defines some common functionality that you can override and extend as appropriate.

With an interface, you can cast an object to the interface (providing it implements it), and call the functionality on it. This is how IDisposable works with the using statement. Effectively, the following code
C#
(using Myclass c = new Myclass())
{
}
translates to
C#
Myclass c = null;
try
{
}
finally
{
  ((IDisposable)c).Dispose();
}
Now, you said "In programming", so there's an additional consideration to take into account. In C#, you cannot have multiple inheritance (where you can in C++). What you can do in C# though, is support multiple interface implementation, so your class can inherit from one class but you can implement many interfaces. You note that I said, in C#, there. There's a common misconception that you can't do multiple inheritance in .NET. That's not true. The constraint is put in place by the language, and not the runtime, so if a .NET language chose to allow multiple inheritance, that would be supported. Until I can find the citation for this, please disregard this statement (it's from a very old interview, so it's taking me some time to find it).

I'm not a stalker, I just know things. Oh by the way, you're out of milk.

Forgive your enemies - it messes with their heads


My blog | My articles | MoXAML PowerToys | Onyx


modified on Thursday, April 14, 2011 8:22 AM

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 
QuestionLinkedList<T> since .NET 2 [modified] Pin
devvvy13-Apr-11 15:55
devvvy13-Apr-11 15:55 
AnswerRe: LinkedList since .NET 2 Pin
OriginalGriff14-Apr-11 0:10
mveOriginalGriff14-Apr-11 0:10 

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.