Sponsored Ad

Tuesday, May 11, 2010

How to Use Arrays in ASP.NET using C#

How to Use Arrays in ASP.NET using C#

 

You can declare C# arrays in ASPX file using Server tag <% %>.

The string[] strArray = new string[5]; line declares a string array of 5 capacity. next five statements assign the values to this array.

Last statement is trying to print the array values using for loop. Please note that you can not use writeln here for new line. use <br> to get new line after current line.

 

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<body>

<%
string[] strArray = new string[5];
    strArray[0] = "CsharpTalk.com";
    strArray[1] = "Indiahub.com";
    strArray[2] = "SoftwareTestingNet.com";
    strArray[3] = "CsharpHub.com";
    strArray[4] = "SharePointBank.com";

for (int i = 0; i <= 4; i++)
{
    Response.Write(strArray[i] + "<br>" );
}

%>

</body>
</html>

0 comments:

Post a Comment

Sponsored Ad

More Related Articles

Website Update

Followers