
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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.
Example
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()); } }
Output
This is Child Class!
- Related Articles
- What is the difference between method hiding and method overriding in Java?
- What is the difference between method overloading and method hiding in Java?
- What is method hiding in Java and how to use it?
- What is the difference between function overriding and method hiding in C#?
- Difference between Method Overriding and Method Hiding in C#
- What is instance variable hiding in Java?
- What is Data Hiding in Python Object Oriented Programming?
- What is the difference between overriding and hiding in C#?
- Data Hiding in Python
- What secrets are you hiding from your parents?
- instance variable hiding in Java
- Explain about field hiding in java?
- Showing and Hiding widgets in Tkinter?
- How data hiding works in Python Classes?
- Hiding specific data in HANA Modeling View

Advertisements