Wednesday, October 27, 2010

difference between abstract classess and interfaces - II

Summary
An Interface cannot implement methods.
An abstract class can implement methods.



An Interface can only inherit from another Interface.
An abstract class can inherit from a class and one or more interfaces.



An Interface cannot contain fields.
An abstract class can contain fields.



An Interface can contain property definitions.
An abstract class can implement a property.



An Interface cannot contain constructors or destructors.
An abstract class can contain constructors or destructors.



An Interface can be inherited from by structures.
An abstract class cannot be inherited from by structures.



http://en.csharp-online.net/Interfaces_and_Abstract_Classes

[see also
http://en.csharp-online.net/Should_I_use_an_abstract_class_or_an_interface%3F
]

An Interface can support multiple inheritance.
An abstract class cannot support multiple inheritance.



[edit]MSDN references
abstract (C# Reference)
Abstract and Sealed Classes and Class Members (C# Programming Guide)
Interfaces (C# Programming Guide)
Should I use an abstract class or an interface?

No comments:

Post a Comment