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