---
title: "Method overloadind and Method Overriding in C#"  
description: "Method Overriding is the feature of compile time Polymorphism.In Which More than One  Method name is same but have different parameter/Signature in th"  
author: "Manish Kumar"  
published: 2017-01-13  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/12227/method-overloadind-and-method-overriding-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Method overloadind and Method Overriding in C#

##

##### Method Overriding

Method Overriding is the feature of compile time [Polymorphism](https://www.mindstick.com/articles/32/polymorphism).In Which More than One [Method name](https://www.mindstick.com/forum/33583/selector-creation-with-method-name-and-parameter) is same but have different parameter/[Signature](https://www.mindstick.com/interview/516/explain-about-xml-signature) in the same Class. At Compile time the compiler check which one is going to be call.

```
   static void str(int x)        {            Console.WriteLine("interger");        }         static void str(string y)        {            Console.WriteLine("string");        }               public static void Main()        {            str("Mindstick");        }
```

##### Out put :

Stirng\

In this example I have maded two function with same name but given different parameter in first method it is of integer type and in another method I have given string type.When we compile this program it check first from the parameter given in the main function and it is of string type so it will call string type of method.

##### Method Overloading

Method Overloading is the feature of runtime polymorphism .In which more than one one method name is similar with same signature .But in different Classes.Method Overriding use two keywords that is Virtual and Override.Virtual in [Base Class](https://www.mindstick.com/blog/116/base-class-initilization)/Parent Class and Override in Inheritence Class/[Child Class](https://www.mindstick.com/forum/159389/how-to-remove-child-class-from-active-div).It is Possible in [Derived class](https://answers.mindstick.com/qa/30686/what-is-a-base-class-and-derived-class) only by the help of virtual or abstract keyword.

Let us take a example to understand Method Overriding

```
using System;  namespace ConsoleApplication2{    class Program    {        class Parent        {            public virtual int balance()            {                return 10;            }            public Parent()            {              Console.WriteLine("Im in Parent Constructor");            }        }         class Child : Parent        {            public override int balance()            {                return 20;            }              static void Main(string[] args)            {                Child obj = new Child();                                var val = obj.balance();                Console.WriteLine(val);                Console.Read();               }        }                     }}
```

\

##### Output

\

```

```

\

\

In the above example child class is inheriting parent class it have two method with same name and have same argument and from main class I have maken the object of class and called balace .

## *\*

## *You can also visit these useful related post*

[*Method Overloading and Overriding in C#*](https://www.mindstick.com/blog/549/method-overloading-and-overriding-in-c-sharp)

*[Method Overloading in C#](https://www.mindstick.com/blog/503/method-overloading-in-c-sharp)\*

[*How is method overriding different from method overloading?*](https://www.mindstick.com/Interview/2053/how-is-method-overriding-different-from-method-overloading)

*Why method overloading is not possible by changing the return type in java*

## *Thank you..*

---

Original Source: https://www.mindstick.com/articles/12227/method-overloadind-and-method-overriding-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
