C# Method Overriding1 min read

Method overriding is done through inheritance, it allows us to define a method at a derived class with the same name present in a base class with the same signature and same return type then the method in a base class is said to be overridden.

In method overriding, the base class method uses virtual keyword while the derived class method uses override keyword.

Method overriding is one of the ways through which C# achieves Run Time Polymorphism (Dynamic Polymorphism). The decision made to call the required function is done at the run time. Hence, it is a Runtime polymorphism.

Example: C# program for method overriding.

Output:

Dog Sleeps
Animals Sleeps


MORE

Keith Number Program in C

In this tutorial, we will write a Keith number in C. It is one of the most asked questions in an interview. Before that, you …
Read More

Keith Number Program in C++

In this tutorial, we will write a Keith number in C++. It is one of the most asked questions in an interview. Before that, you …
Read More

Singly linked list Program C++

In this tutorial, we will write a C++ program to implement singly linked list. In this program, we will create a separate function for each …
Read More

Fascinating Number Program in C

In this tutorial, we will write a C program to check whether the given number is a Fascinating number or not. You may go through …
Read More

Peterson Number in C

In this tutorial, we will learn about the Peterson number and check if the number is Peterson or not in C. What is Peterson Number? …
Read More

Peterson Number in C++

In this tutorial, we will learn about the Peterson number and write a C++ program to check if the given number is a Peterson number …
Read More