This is a C# Program to demonstrate the concept of overriding.
This C# Program Demonstrates the concept of Overriding.
Here the override modifier is required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event.
Here is source code of the C# Program to Demonstrate the concept of Overriding. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Demonstrate the concept of Overriding */ using System; abstract class ShapesClass { abstract public double Area(); } class Circle : ShapesClass { int radius = 0; public Circle(int n) { radius = n; } public override double Area() { return 3.14 * radius * radius; } static void Main() { int r; Console.WriteLine("Enter the Radius :"); r = int.Parse(Console.ReadLine()); Circle c1 = new Circle(r); Console.WriteLine("Area of the Circle = {0}", c1.Area()); Console.ReadLine(); } }
In this C# Program, we are reading the radius of the circle using ‘r’ variable. Perform the operations of Circle() function by passing ‘r’ variable value as an argument. The override modifier is required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event.
Enter the Radius : 3 Area of the Circle : 28.26
Sanfoundry Global Education & Learning Series – 1000 C# Programs.
- Get Free Certificate of Merit in C# Programming
- Participate in C# Programming Certification Contest
- Become a Top Ranker in C# Programming
- Take C# Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Buy C# Books
- Buy Computer Science Books
- Buy MCA Books
- Apply for Computer Science Internship
- Practice MCA MCQs