What is method hiding in C#?

Method hiding is also known as shadowing. The method of the parent class is available to the child class without using the override keyword in shadowing. The child class has its own version of the same function.

Use the new keyword to perform shadowing.

Let us see an example.


 Live Demo

using System;
using System.Collections.Generic;

class Demo {
   public class Parent {
      public string GetInfo () {
         return "This is Parent Class!";

   public class Child : Parent {
      public new string GetInfo() {
         return "This is Child Class!";

   static void Main(String[] args) {
      Child child = new Child();
      Console.WriteLine(child. GetInfo());


This is Child Class!
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know