What is abstract properties and how to use abstract properties in C#

Description

Abstract properties are defined in the parent class and waiting for child class to provide implementation.

Example

Example for C# Abstract Properties


using System;//from   w  w  w .  ja v a  2 s .  c  om

public abstract class Employee
{
    public abstract string Name
    {
        get;
    }
}
class Engineer: Employee
{
    string name = "Engineer";
    
    public override string Name
    {
        get
        {
            return(name);
        }
    }
}
class MainClass
{
    public static void Main()
    {
        Employee d = new Engineer();
        Console.WriteLine("Name: {0}", d.Name);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Custom Types »




C# Class
C# Struct
C# Interface
C# Inheritance
C# Namespace
C# Object
C# Delegate
C# Lambda
C# Event
C# Enum
C# Attribute
C# Generics
C# Preprocessor