当前位置:网站首页>ASP. Net razor – introduction to VB loops and arrays
ASP. Net razor – introduction to VB loops and arrays
2022-07-04 12:16:00 【wx5a20cf699eb6f】
Razor Not a programming language . It's a server-side markup language .VB Loops and arrays : Statements are repeated in the loop . |

For loop
If you need to repeat the same statement , You can set a loop .
If you know how many times to loop , You can use for loop . This type of loop is particularly useful when counting up or down :
example
<html>
- 1.
<body>
- 1.
@For i=10 To 21
@<p>Line #@i</p>
- 1.
- 2.
Next i
- 1.
</body>
- 1.
</html>
- 1.
For Each loop
If you are using a collection or array , You will often use for each loop .
A collection is a group of similar objects ,for each The loop can traverse the collection until it is complete .
In the following example , Traverse ASP.NET Request.ServerVariables aggregate .
example
<html>
- 1.
<body>
- 1.
<ul>
- 1.
@For Each x In Request.ServerVariables
@<li>@x</li>
- 1.
- 2.
Next x
- 1.
</ul>
</body>
- 1.
- 2.
</html>
- 1.
While loop
while A loop is a generic loop .
while Cycle to while Keyword start , Followed by parentheses , You can specify in parentheses how long the cycle will last , Then there are repeated code blocks .
while Loops usually set an increasing or decreasing variable to count .
In the following example ,+= Operator gives the variable... Every time the loop is executed i The value of the add 1.
example
<html>
- 1.
<body>
- 1.
@Code
- 1.
Dim i=0
- 1.
Do While
i<5
i += 1
@<p>Line #@i</p>
- 1.
- 2.
- 3.
- 4.
Loop
End Code
- 1.
- 2.
</body>
- 1.
</html>
- 1.
Array
When you want to store multiple similar variables, but you don't want to create a separate variable for each variable , You can use arrays to store :
example
@Code
- 1.
Dim members As String()={"Jani","Hege","Kai","Jim"}
- 1.
i=Array.IndexOf(members,"Kai")+1
- 1.
len=members.Length
- 1.
x=members(2-1)
end Code
- 1.
- 2.
<html>
- 1.
<body>
- 1.
<h3>Members</h3>
- 1.
@For Each person In members
@<p>@person</p>
Next person
- 1.
- 2.
- 3.
<p>The number of names
in Members are @len</p>
- 1.
- 2.
<p>The person at
position 2 is @x</p>
- 1.
- 2.
<p>Kai is now in
position @i</p>
- 1.
- 2.
</body>
- 1.
</html>
- 1.
This paper addresses : https://www.linuxprobe.com/asp-net-razor.html
边栏推荐
- (August 9, 2021) example exercise of air quality index calculation (I)
- VBA, JSON interpretation, table structure -json string conversion
- Enter the smart Park, and change begins here
- SAP ui5 date type sap ui. model. type. Analysis of the display format of date
- MPLS experiment
- Attributes and methods in math library
- Application of slice
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
- netstat
- Definition and method of string
猜你喜欢

Ultimate bug finding method - two points

The detailed installation process of Ninja security penetration system (Ninjitsu OS V3). Both old and new VM versions can be installed through personal testing, with download sources

Application of slice

Using terminal connection in different modes of virtual machine

Function parameters (positional parameters, default value parameters, variable parameters, named keyword parameters, keyword parameters)

What if the chat record is gone? How to restore wechat chat records on Apple Mobile
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12](/img/b1/926d9b3d7ce9c5104f3e81974eef07.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12

Serialization oriented - pickle library, JSON Library

SAP ui5 date type sap ui. model. type. Analysis of the display format of date

Experiment 7. IPv6
随机推荐
How to judge the advantages and disadvantages of low code products in the market?
13、 C window form technology and basic controls (3)
Detailed explanation of classic process synchronization problems
Ternsort model integration summary
Lecture 9
Memory computing integration: AI chip architecture in the post Moorish Era
Here, the DDS tutorial you want | first experience of fastdds - source code compilation & Installation & Testing
2021-10-20
Heartbeat error attempted replay attack
Summary of Shanghai Jiaotong University postgraduate entrance examination module -- cryptography
nn. Exploration and experiment of batchnorm2d principle
Awk getting started to proficient series - awk quick start
Automatic translation between Chinese and English
The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
First knowledge of spark - 7000 words +15 diagrams, and learn the basic knowledge of spark
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
Process communication and thread explanation
No response after heartbeat startup
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 10