C# Abstract Properties

In this chapter you will learn:

  1. What is abstract properties
  2. Example for C# Abstract Properties

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 ww  .ja v  a  2 s  . c  o  m*/

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.

Next chapter...

What you will learn in the next chapter:

  1. What is an Indexer
  2. How to create an Indexer
  3. Example for creating an indexer
  4. How to create a getter only indexer
Home »
  C# Tutorial »
    C# Types »
      C# Properties
C# Properties
C# property accessor modifiers
C# read or write only property
C# Automatic properties
C# Static Properties
C# Abstract Properties