www.c-sharpcorner.com/UploadFile/8a67c0/method-overloading-and-method-overriding-in-C-Sharp/
1 Users
0 Comments
5 Highlights
0 Notes
Tags
Top Highlights
There are two types of Polymorphism, Method Overloading Method Overriding
Method Overloading is a type of polymorphism. It has several names like “Compile Time Polymorphism” or “Static Polymorphism” and sometimes it is called “Early Binding”. Method Overloading means creating multiple methods in a class with same names but different signatures (Parameters). It permits a class, struct, or interface to declare multiple methods with the same name with unique signatures. Compiler automatically calls required method to check number of parameters and their type which are passed into that method.
Note: Changing the return type of method does not make the method overloaded. You cannot create method overloaded vary only by return type.
Method Overriding is a type of polymorphism. It has several names like “Run Time Polymorphism” or “Dynamic Polymorphism” and sometime it is called “Late Binding”. Method Overriding means having two methods with same name and same signatures [parameters], one should be in the base class and other method should be in a derived class [child class]. You can override the functionality of a base class method to create a same name method with same signature in a derived class. You can achieve method overriding using inheritance. Virtual and Override keywords are used to achieve method overriding.
Points to be remembered, Method cannot be private. Only abstract or virtual method can be overridden. Which method should be called is decided at run time.
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.