VKinfotek Inc.
  • Us
    About Us
    Contact Us
  • FAQs
  • Ready Software
    Ready ERP ASP Core Software for Azure Cloud
    Ready Web ERP Software
    Ready ASP.Net Azure Software
    Ready C# SQL Server Accounting Software
    Ready ASP.Net MVC and EF Software
First slide
Earn $100/hour in USA! Click Here

abstract class inheritance in c#.net

Implementing abstract class in c#.net is similar to that in Visual Basic.net. However, there is a difference in syntax while creating abstract class, abstract members and derived class in c#.

Click here to know How to use abstract class inheritance in Visual Basic.Net.

To declare an abstract class in c#, we need to declare it using the abstract keyword in the class declaration. The following code demonstrates abstract class inheritance in c#.net.

abstract class Employee : 
    {
private string  mFirstName;
private string mLastName;
        public Employee(string fname, string lname)
        {
          mFirstName = fname;
          mLastName = lname;
        }
        public Employee()
        { 
        }
        public string FName
        {
            get
            {
                return mFirstName;
            }
            set
            {
                mFirstName = value;
            }
        }
        public string LName
        {
            get
            {
               return mLastName;
            }
            set
            {
                mLastName = value;
            }
        }
        public abstract double InComeEarned();
    }


Abstract members of an abstract class do not contain any implementation code. Abstract methods are declared using the abstract keyword as shown in above code. These abstract methods are overridden by subclasses and so there is no implementation in the abstract methods.

The syntax for deriving a class from a base class or from an abstract base class is similar. The following code derives a class - 'RegularEmployee' from an abstract class - 'Employee'.

Implementing Abstract Class in C#.

The next step is to implement the abstract method InComeEarned() in the derived class. To implement abstract members in a derived class, the override keyword must be used.

class RegularEmployee : Employee
    {
        private double  mSalary;
    public RegularEmployee(string fname, string lname, double salary)   : base()
    {
        mSalary = salary;
     }
    public double Salary
    {
        get
        {
            return mSalary;
        }
        set
        {
           mSalary = value;
       }
    }
        public override  double InComeEarned()
        {
             return Salary;
        }


Object Oriented Programming Articles
  • Abstract class constructors
  • abstract class inheritance in c#.net
  • abstract class inheritance in visual basic.net
  • New C# Language Feature: Automatic Properties
  • Calling base class constructor in C#
  • base keyword in c#
  • Compile time polymorphism - Method OverLoading
  • How to initialize Base class Object from inside Derived Class constructor
  • Constructor overloading in vb.net
  • How to use inheritance in c#
  • How to use inheritance in visual basic.net
  • Parameter array in vb.net
  • Procedure OverLoading in vb.net
  • Visual Inheritance with Windows Forms
  • Azure Platform
  • GridView CommandField example
  • GridView and DetailsView Master/Detail page using SqlDataSource control
  • POCO overview and advantages - POCO class, Entity Framework in Enterprise Applications
  • Query entity data model using linq to entities
  • Difference between arraylist and list collection
  • How to create a Web service using Visual Studio.net
  • FormView DataBound Event
  • Calling base class constructor in C#
  • Convert a sequence to a generic list using ToList()method
  • Project ideas for students
  • Accounting Software
  • Creating an ASP.Net MVC 3 application
  • Using assemblies in .net applications
  • How to implement form validation using ASP.Net 2.0 Validation Controls
  • Constructors in Visual Basic.Net
People also viewed: cover image of book develop erp software using asp core and deploy to Azure Create your own ERP Software using ASP Core>>
cover image of azure cloud book Create your own Azure SOM Software>>
cover image of asp.net book Create your own ERP Software using ASP .Net and SQL>>
cover image of foundation database programming book Create your own Accounting Software using C# >>
cover image of entity framework book Create your own SOM using Entity Framework MVC >>


  • SITEMAP
  • Terms of use
  • Testimonials

Back to top

Copyright © 2016 - All Rights Reserved - VKInfotek.com