Enter the Radius : 3 Area of the Circle : 28.26
Users Online
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Latest Articles
Articles Hierarchy
C# Program to Demonstrate the Overriding
C# Program to Demonstrate the Overriding
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.