当前位置:网站首页>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
边栏推荐
- Video analysis
- DVC use case (VI): Data Registry
- Lecture 9
- Properties and methods of OS Library
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 6
- [ES6] template string: `string`, a new symbol in es2015
- Star leap plan | new projects are continuously being recruited! MSR Asia MSR Redmond joint research program invites you to apply!
- Classification and application of AI chips
- Xshell's ssh server rejected the password, failed to skip publickey authentication, and did not register with the server
- SSH principle and public key authentication
猜你喜欢

Practical dry goods: deploy mini version message queue based on redis6.0

(August 9, 2021) example exercise of air quality index calculation (I)

Source code analysis of the implementation mechanism of multisets in guava class library

2021-08-09

TCP slicing and PSH understanding

nn. Exploration and experiment of batchnorm2d principle

How to create a new virtual machine
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 11](/img/6a/398d9cceecdd9d7c9c4613d8b5ca27.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 11

2018 meisai modeling summary +latex standard meisai template sharing

Realize cross tenant Vnet connection through azure virtual Wan
随机推荐
Recommend a cool geospatial data visualization tool with low code
LVS load balancing cluster deployment - Dr direct routing mode
Reptile learning 4 winter vacation series (3)
Review of week 278 of leetcode II
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 10
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 22
Common built-in modules
Definition and method of string
Practical dry goods: deploy mini version message queue based on redis6.0
Detailed array expansion analysis --- take you step by step analysis
Configure SSH certificate login
LxC shared directory permission configuration
C language memory layout
priority_ queue
thread
Supercomputing simulation research has determined a safe and effective carbon capture and storage route
Customized version of cacti host template
os. Path built-in module
Ternsort model integration summary
. Does net 4 have a built-in JSON serializer / deserializer- Does . NET 4 have a built-in JSON serializer/deserializer?