Method overloading is a process in which we create the method with the same name with different parameter.
There are three types of method overloading in c# which is as follows.
Public int sum(int x, int y)
{
Return x+y;
}
Public int sum(int x, int y, int z)
{
Return x=y+z;
}
{
Return x+y;
}
Public string sum(string x, string y)
{
Return x+y;
}
public string sum(string x, int y)
{
Return x+y;
}
Note - Return type does not bother in method overloading.
There are three types of method overloading in c# which is as follows.
- Number of Parameter- in number of parameter we change the count of parameter to the method of same name.
Public int sum(int x, int y)
{
Return x+y;
}
Public int sum(int x, int y, int z)
{
Return x=y+z;
}
- Data Type of Parameter-we will simply change the data type of parameter passing to the method of same name.
{
Return x+y;
}
Public string sum(string x, string y)
{
Return x+y;
}
- Sequence of Parameter- In the third rule of method overloading we can change the sequence of parameter of same method.
public string sum(string x, int y)
{
Return x+y;
}
Note - Return type does not bother in method overloading.
Comments
Post a Comment