Partial Class Implementation Abstract Classes

By: Jesse Miller

C sharp enables you to create abstract classes that are used to provide partial class implementation of an interface. Complete implementation can be achieved by using the derived class. Polymorphism can be implemented by using abstract classes and virtual functions.

Derived classes help you provide more specialized functionality. Polymorphism enables you to treat the new objects as general objects. This class is created by using the abstract keyword. There are certain rules which govern the use of an abstract class.

Creation of an instance of an abstract class, and declaring an abstract method outside an abstract class can never happen. Declaring a class as sealed gives an error. Sealed classes can never be inherited.

Abstract methods are methods without any body. The implementation of an abstract method is done by the derived class. When a derived class inherits the abstract method from the abstract class, it must override the abstract methods. This requirement is enforced at compile time, and is also called dynamic polymorphism.

Virtual function could be implemented by the inherited classes in their own way and the method is decided at runtime. Function which is defined in a class can be implemented by the inherited classes through virtual function.

There are many times when a class need not be extended. Also there would be a need where deliberately you force to inherit a class. Users can be restricted from inheriting the class by sealing the class using the sealed keyword.

The keyword tells the compiler that the class is sealed class. A method can also be sealed, and in that case, the method cannot be overridden.
An interface defines the syntactical contract that all the derived classes should follow.

Specifically the interface defines what part of the syntactical contract, and the classes implementing the interface describe the how part of the contract. C sharp has full support of interfaces.

Interface also defines properties, methods, and events, which are known as the members of the interface. It is important to note that interfaces contain only the declaration of members.

Classes and structures implement these interface members. Interface is used when you want a standard structure of methods to be followed by the classes, where classes will implement the functionality.

Quick Note: Taking the Nonsense out of looking for the right spyware remover

If you really want to take the work out of looking for that right Spyware Protection from a go to the Internet and get a or a Free
Download, In order to prevent your vital information from being ripped from your computer get your Remover Today.

Whereas, abstract classes are used in the situation where you want only few methods to declare by the base class and the derived class will implement the functionality with ease.

Top Searches on
Computers
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 

» More on Computers