Dec 11, 2019

METHOD OVERLOADING IN C#


OVERLOADING
c# overload, method overloading with different return type in c#, method overloading in c# tutorialspoint, function overloading in c# with example, method overloading and overriding in c# with example
method overloading in c#

            “The mechanism of creating more than one of a class member of same name in a class is called Overloading.”
 If we create more than one method or constructor in a Class with same name then the Class will have method and constructor Overloading.
            Overloading is found when same name for the class member by different rules which are,
            1.    Different number of parameter
            2.    Different type of parameter
            3.    Different sequence of parameter

METHOD OVERLOADING

  What is method? Seeit,
"Method overloading is the mechanism of creating more than one method in a class by same name for the method". But there will some different rules in all method that’s,

      1.    METHOD OVERLOADING OF DIFFERENT  NUMBER OF PARAMETER

The overloading of method in a class due to creating same name of methods but
providing different number of parameters of same data type to that’s method. 
For example suppose method name are Arthematic,
Public class Evaluation
{
   Public void Aithematic (int a, int b)
      {
Do this;
      }
   Public void Aithematic (int a, int b, int c)
      {
Do this;
      }
   Public void Aithematic (int a, int b, in t c, int d)
     {
Do this;
      }
}

      2.    METHOD OVERLOADING OF DIFFERENT TYPE OF PARAMETER

The overloading of method in a class due to creating same name of methods but
providing different types of parameter. 
For example suppose method name are Arthematic,
Public class Evaluation
{
   Public void Aithematic (int a, double b)
      {
Do this;
      }
   Public double Aithematic (int a, double b, decimal c)
      {
Do this;
      }
   Public void Aithematic (int a, double b, decimal c, float d)
     {
Do this;
      }
}

      3.    METHOD OVERLOADING OF DIFFERENT SEQUENCE OF PARAMETER

The overloading of method in a class due to creating same name of methods but
makes different sequence of parameter. 
For example suppose method name are Arthematic,
Public class Evaluation
{
   Public void Aithematic (int a, decimal b, double c)
      {
Do this;
      }
   Public double Aithematic (double a, int b, decimal c)
      {
Do this;
      }
}

See example of method overloading in c#.

0 comments:

Post a Comment

Please do not enter any spam link in the comment box