Saturday, November 2, 2019

What is Method Overloading?

Method Overloading is the regular method for actualizing polymorphism. It is the capacity to rethink a capacity in more than one structure. A client can execute capacity over-burdening by characterizing at least two capacities in a class having a similar name. C# can recognize the strategies with various technique marks. for example the techniques can have a similar name yet with various parameters list (for example the quantity of the parameters, request of the parameters, and information sorts of the parameters) inside a similar class.

Overload techniques are separated dependent on the number and sort of the parameters went as contentions to the strategies.

You can not characterize more than one technique with a similar name, Order and the sort of the contentions. It would be compiler blunder.

The compiler doesn't consider the arrival type while separating the over-burden strategy. Yet, you can't announce two strategies with a similar signature and diverse return type. It will toss an arrange time blunder. In the event that the two strategies have a similar parameter types, however unique return type, at that point it is preposterous.

Why do we need Method Overloading ??

On the off chance that we have to do a similar sort of the activity in various manners for example for various information sources. In the model depicted beneath, we are doing the expansion activity for various sources of info. It is elusive a wide range of significant names for single activity.

Different ways of doing overloading methods-

  1. The data types of the parameters is different in different methods of same name. 
  2. The number of parameters is different in two or more methods of same name .
  3. The Order of the parameters of methods is different.

1. The data types of the parameters is different in different methods of same name. 









2. The number of parameters is different in two or more methods of same name.








3. The Order of the parameters of methods is different.






No comments:

Post a Comment