
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What are abstract properties in C#?
An implementation of the property accessors will not be provided by an abstract property declaration.
Let us see how to learn how to work with abstract properties. Here we have an abstract class Shape with two derived classes: Square and Circle.
Here, we have an abstract Area property.
The following is the Circle class.
Example
public class Circle : Shape { private int radius; public Circle(int radius, string id) : base(id) { this.radius = radius; } public override double Area { get { return radius * radius * System.Math.PI; } } }
In the same way, the Square class.
Example
public class Square : Shape { private int side; public Square(int side, string id) : base(id) { this.side = side; } public override double Area { get { return side * side; } } }
The following is the Shape class, which is abstract.
Example
public abstract class Shape { private string name; public Shape(string s) { Id = s; } public string Id { get { return name; } set { name = value; } } public abstract double Area { get; } public override string ToString() { return Id + " Area = " + string.Format("{0:F2}", Area); } }
- Related Articles
- What are abstract classes in Java?
- what are abstract methods in Java?
- What are abstract classes in C#?
- What are final, abstract, synchronized non-access modifiers in Java?
- What are accessors of properties in C#?
- What are the properties of subtraction?
- What are the properties of light?
- What are the properties of Materials
- What does abstract modifier in Java do?
- What are the properties of a parallelogram?
- What are the properties of the triangle?
- What are the properties of window.screen object in JavaScript?
- What are the properties of array class in C#?
- What are the basic properties of products in TOC?
- What are the properties of Regular expressions in TOC?

Advertisements