65.9K
CodeProject is changing. Read more.
Home

Interface, abstract, partial and sealed classes

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.18/5 (4 votes)

Oct 11, 2013

CPOL
viewsIcon

40304

InterfaceAn interface is like a class but all themethods and properties are abstract. An Interface cannot beinstantiated like abstract class. All

Interface

An interface is like a class but all the methods and properties are abstract. An Interface cannot be instantiated like abstract class. All the methods and properties defined in Interface are by default public and abstract.

Interface generally refers to an abstraction that an entity provides of itself to the outside. Interface can help in separating the methods for external and internal communication without effecting in the way external entities interact with the type.. 

 Abstract Class

 An abstract class is a class with at least one method defined as abstract. This type of class cannot be instantiated. An abstract class can have one or more abstract methods and properties and other methods and properties like normal classes.

Partial Class 

A class defined in  two or more files is called a partial class. The keyword partial is used to define the class. When working on large projects, spreading a class over separate files allows multiple programmers to work on it simultaneously. During compile time all the partial class are compiled into one type only.

Sealed Class

 A sealed class is a class that cannot be inherited. Sealed classes are used to restrict the inheritance feature of object oriented programming.