In this chapter you will learn
You can use single-dimensional array and multi-dimensional array inside razor syntax as follow- How to use array inside Razor Syntax
- Single-Dimensional Array and Multi-Dimensional Array
- Programming Example
<html lang="en"> <head> <meta charset="utf-8" /> <title></title> </head> <body> @{ //Single Dimensional Array <h3>Single Dimensional Array</h3> int[] arr={1,3,5,7,11,13,17,19}; foreach(int x in arr) { <span>@x, </span> } //Multi Dimensional Array <h3>Multi Dimensional Array</h3> string[,] letter=new string[3,2] {{"a","b"},{"c","d"},{"e","f"}}; for(int i=0; i<3; i++) { for(int j=0; j<2; j++) { <span>@letter[i,j], </span> } <br /> } } </body> </html>Output
Single Dimensional Array
1, 3, 5, 7, 11, 13, 17, 19,
Multi Dimensional Array
a, b,
c, d,
e, f,