Skip to main content

What is Array in C#

Array is a collection of similar data types. In array we access the value using index.
Declaration of array
Int [ ] marks = new int [5];
Assigning value to the array
  1. Marks [0] = 90; Marks[1] = 80;
  2. Int [ ] marks = new int [ 5 ] { 2, 3,4,5,6 }
  3. Int [ ] marks = { 2, 3, 4,5, 6,7,8}
Retrieving value from Array
int Sum = 0;
For (int i=0; i<= marks. Length; i++)
{
Sum = Sum + marks [i];
}
Response. Write (sum);

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;