Mega Code Archive

 
Categories / ASP.Net Tutorial / Collections
 

Define and use array in asp net page (C#)

<%@ Page Language="C#" %> <script runat="server">    string[] arrColors = new string[5];        void Page_Load(Object Sender, EventArgs e) {       arrColors[0] = "green";       arrColors[1] = "red";       arrColors[2] = "yellow";       arrColors[3] = "blue";       arrColors[4] = "violet";              Response.Write("The first element is: ");       Response.Write(arrColors[0] + "");              Response.Write("The third element is: ");       Response.Write(arrColors[2] + "");              Response.Write("The 5-3 element is: ");       Response.Write(arrColors[5-3] + "");    } </script> <html><body> </body></html>