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

List Controls: List Box and Drop Downlist

ASP.Net provides the controls: drop-down list, list box, radio button list, check box list and bulleted list. These control let a user choose from one or more items from the list. List boxes and drop-down list contain one or more list items. These lists could be loaded either by code or by the ListItem Collection Editor. Basic syntax for list box control: <asp:ListBox ID="ListBox1"        runat="server"        AutoPostBack="True"        OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"> </asp:ListBox> Basic syntax for a drop-down list control: <asp:DropDownList ID="DropDownList1"       runat="server"       AutoPostBack="True"       OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> </asp:DropDownList>

Sql CharIndex Function

The CHARINDEX  function returns the starting position of the specified expression in a character string. Example: Search for "t" in string "DotNetReceipe", and return position: SELECT CHARINDEX( 't' , 'DotNetReceipe' ) AS Position;