ASP.NET Razor Control StructuresControl structures are control statements that are used to control program flow. C# programming language uses if, else, if else, switch, for, foreach, while to perform conditional logic in the application. Razor engine supports all these controls in the view file. Let's see some examples that implements control structure using razor syntax. @if// RazorControlStructure.cshtml Output: It produces the following output. ![]() Else and Else IfThe @ (at) symbol is not require in else and else if statements. // RazorControlStructure.cshtml Output: ![]() @switch Example// RazorControlStructure.cshtml Output: ![]() @for// RazorControlStructure.cshtml Output: It produces the following output. ![]()
Next TopicASP.Net Razor HTML Helpers
|