In this program, we are going to share C# program to describe the C# program illustrate method hiding.
To increase your C# knowledge, practice all C sharp programs:
Copy the below c# program and execute it in your Microsoft Visual Studio IDE (Integrated Development Environment ). At the end of this program, I have shared the output program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { public class Demo { public virtual double Area(double r) { return r * r; } public void func() { Console.WriteLine("Base Class"); } } public class A : Demo { public override double Area(double r) { return base.Area(r) * r; } public new void func() { Console.WriteLine("Derived Class"); } } public class Test { public static void Main(string[] args) { A o1 = new A(); Console.WriteLine(o1.Area(20)); o1.func(); Console.ReadLine(); } } } |
8000
Derived Class
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.