Asp.net Array (Array) can be considered as a variable that stores multiple values of the same data type. Multiple values are distinguished by the same variable name and different index values. It is used to store data of the same nature or type.
1. ASP. NET array declaration
The declaration of arrays can be in the following two formats:
Dim array name (number of elements) As data type]
Dim array name () As data type] = {element value l, element value 2 ...}
2. Expression of ASP. NET array elements
After an array is declared and its elements are assigned, the array can be executed. The element expression of the array is as follows:
Array name (index value) = element value
Tip: the index value is calculated from O. You can declare a maximum of 264 elements (the Long type ).
3. ASP. NET array example
Compile an ASP program and use the array to create a webpage.
Display the date of the current day.
- <Html>
- <Hr>
- <%
- Dim cw (7)
- Cw (O) = "Sunday ".
- Cw (1) = "Monday"
- Cw (2) = "Tuesday"
- Cw (3) = "Wednesday"
- Cw (4) = "Thursday"
- Cw (5) = "Friday"
- Cw (6) = "Saturday"
- Response. write (today is? & yea r (now ())&"Year")
- Response. write (month (now ())&"Month"& Day (now ())&"Day")
- Response. write (cw (Wee kDay (now () 1 ))
- %>
- <Hr>
- </Html>
The procedure is described as follows:
Lines 5 from 3rd to 1: the entity of the ASP program.
Row 4th: declares an array CW, with seven elements in the array.
5th ~ Row 11: defines each element in the array. The data type is a string.
1st 2-1 4 rows: Use the date and time function and array to output the date using the write method of the response object, where in line 4 of l, use the WeekDay function. the A, now () function is used to obtain the week value. The value range is 1 ~ 7. Because the index value in the array is to be substituted into the index value, and the index value in the array is calculated from O, 1 is required in this output program, and the calculated week value range is set to O ~ 6, to match the index value of the array, to bring out the string represented by each index value.
The above is the application of ASP. NET array.
- Introduction to ASP. net mvc Framework
- Introduction to MvcAjaxPanel in ASP. NET MVC
- ASP. net mvc Framework to save UpdatePanel
- Use ASP. net mvc source code to find a solution
- ActionInvoker of ASP. net mvc Framework