OVERLOADING
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
"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;
}
}
0 comments:
Post a Comment
Please do not enter any spam link in the comment box