Tuesday, April 20, 2010

Abstract Classes Vs Interface

Interface
An interface is a reference type containing only abstract members. These can be events, indexers, methods or properties, but only the member declarations. A class implementing an interface must provide the implementation of the interface members. An interface cannot contain constants, constructors, data fields, destructors, static members or other interfaces. Interface member declarations are implicitly public.


Abstract Class

Like an interface, you cannot implement an instance of an abstract class, however you can implement methods, fields, and properties in the abstract class that can be used by the child class.



* 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.


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

For More help please follow...........

No comments:

Post a Comment