Hiding Method In C#

Now we are learning about the hiding method in C#.
  • 2022

Introduction

In some cases we want to implement base class into the derived class but it's method independent in the base class .means that description together.
Method hiding is interrelated to the function of c++ overriding.
There is a example of method hiding in C#.
Example

class Abc

    {

        public void Display()

        {

           System . Console.WriteLine("Abc method");

        }

   }

    class Child : Abc

    {

        public new void Display()

        {

           System.Console.WriteLine("derived method");

       }

     }

    class PQR

    {

        public static void Main()

        {

            Child  c = new Child ();

            c.Display();

            System.Console.ReadLine();

                }

          }

    }

Output

hidmathod.jpg

 

 

 

 

© 2020 DotNetHeaven. All rights reserved.