Skip to main content

Method/Function Overloading in C#

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.
  1. Number of Parameter- in number of parameter we change the count of parameter to the method of same name.
For example
Public int sum(int x, int y)
{
Return x+y;
}
Public  int sum(int x, int y, int z)
{
 Return x=y+z;
}
  1. Data Type of Parameter-we will simply change the data type of parameter passing to the method of same name.
public int sum(int x , int y)
{
 Return x+y;
}
Public string sum(string x, string y)
{
Return x+y;
}
  1. Sequence of Parameter- In the third rule of method overloading we can change the sequence of parameter of same method.
Example
public string sum(string x, int y)
{
Return x+y;
}
Note - Return type does not bother in method overloading.

Comments

Popular posts from this blog

Asp.net Component Model

ASP.Net Component Model: The ASP.Net component model provides various building blocks of ASP.Net pages. Basically it is an object model, which describes: ·          Server side counterparts of almost all HTML elements or tags, like <form> and <input>. ·          Server controls, which help in developing complex user-interface for example the Calendar control or the Gridview control. ASP.Net is a technology, which works on the .Net framework that contains all web-related functionalities. The .Net framework is made of an object-oriented hierarchy. An ASP.Net web application is made of pages. When a user requests an ASP.Net page, the IIS delegates the processing of the page to the ASP.Net runtime system. The ASP.Net runtime transforms the .aspx page into an instance of a class, which inherits from the base class Page of the .Net framework. Therefore, each ASP.Net page is an object and a...