Wednesday, February 25, 2009

Difference between Interface and Abstract Class - C#

1. A class can implement any number of interfaces, while can subclass at most one abstract class.

2. An abstract class can have non-abstract methods, while the methods of an interface are effectively abstract.

3. An abstract class can declare and use variables while an interface can not

4. An abstract class can have methods whose access is public, internal, protected, protected internal or private. Interface members implicitly have public access and no access modifiers(including public) are allowed on interface member declarations.

5. An abstract class can define constructors while interface cannot.

No comments: