Click here to Skip to main content
15,881,757 members
Articles / Programming Languages / Visual Basic

Abstract Class versus Interface

Rate me:
Please Sign up or sign in to vote.
4.76/5 (382 votes)
7 Jan 2008CPOL4 min read 2.6M   11.1K   559  
Abstract class versus Interface: Usage and Implementation.
This article is meant to be a theoretical and practical overview of Interfaces and Abstract classes. In the article, I have explain the differences between an abstract class and an interface. I have also implemented a demo project which uses both abstract class and interface and show the differences in their implementation with code examples.
using System;

namespace AbstractsANDInterfaces
{
	/// <summary>
	/// Summary description for IEmployee.
	/// </summary>
	public interface IEmployee
	{
		//cannot have fields. uncommenting will raise error!
//		protected String id;
//		protected String lname;
//		protected String fname;

		//just signature of the properties and methods.
		//setting a rule or contract to be followed by implementations.
		String ID
		{
			get;
			set;
		}

		String FirstName
		{
			get;
			set;
		}
		
		String LastName
		{
			get;
			set;
		}
		
		// cannot have implementation
		// cannot have modifiers public etc all are assumed public
		// cannot have virtual

		String Update();

		String Add();

		String Delete();

		String Search();

		String CalculateWage();
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Australia Australia
Rahman is a very experienced software developer with 10+ years of experience in different programming languages. Has experience in both Web Application Development and Desktop Line of Business Application development.

At the moment his area of interest are .Net both C# and VB.Net, Client side UI frameworks like AngularJs, Bootstrap, etc. Application Architecture, Dependency Injection, Use case Driven Development, Test Driven Development, MOQ etc.

He has Bachelor of Computing with Distinction Grade from University of Western Sydney.

Comments and Discussions