Friday, October 3, 2008
• Abstract classes may provide members that have already been implemented.
Therefore, you can ensure a certain amount of identical functionality with an
abstract class, but cannot with an interface.
• If you anticipate creating multiple versions of your component, create an
abstract class. Abstract classes provide a simple and easy way to version your
components. By updating the base class, all inheriting classes are automatically
updated with the change. Interfaces, on the other hand, cannot be changed
once created. If a new version of an interface is required, you must create a
whole new interface.
• If the functionality you are creating will be useful across a wide range of
disparate objects, use an interface. Abstract classes should be used primarily for
objects that are closely related, whereas interfaces are best suited for providing
common functionality to unrelated classes.
• If you are designing small, concise bits of functionality, use interfaces. If you are
designing large functional units, use an abstract class.
• If you want to provide common, implemented functionality among all
implementations of your component, use an abstract class. Abstract classes
allow you to partially implement your class, whereas interfaces contain no
implementation for any members.
Also Read other Top Articles
- JSON Serialization in VS 2008
- Implementing Forms Authentication in Silverlight Application.
- Making GridView Rows or Individual Cells Clickable and Selectable.
- Enabling browser back button for GridView Paging and Sorting in Ajax 1.1 and 3.5 (using Visual Studio 2005/ Visual studio 2008)
- How to pass values from User Control to Page or calling Page methods from User Control.
- What is WCF?
- New features in C# 4.0
- C# to VB.NET and VB.NET to C# online free converter tools.