Compiler Error Message: CS1513:} Expected

I pass the object from the controller to the view. An object contains the Name, Title, and List of Event properties, such as List Events. You can link here (http://www.asp.net/mvc/tutorials/mvc-music-store-part-4). I am using ASP.NET MVC 3 / C # / and scripts

@model MvcEventCalendar.Models.Category @{ ViewBag.Title = "Browse"; } <h2>Browsing Category: @Model.Name</h2> <ul> @foreach (var event in Model.Events) { <li> @event.Title </li> } </ul> 

The lines have a problem (@foreach (var event in Model.Events)) and (@ event.Title). Object events are not displayed in the Model. Similarly, the name is not displayed for the event. Intellisense doesn't display anything

Compiler Error Message: CS1513:} Expected

Source Error:

 Line 8: Line 9: <ul> Line 10: @foreach (var event in Model.Events) Line 11: Line 12: { 
+4
source share
1 answer

event is a fallback word in C # .. you can try @event (well maybe not in razor syntax now when I think about it). But seriously rename the variable event ..

 @foreach (var theEvent in Model.Events) { <li> @theEvent.Title </li> } 

Keywords C #

+8
source

Source: https://habr.com/ru/post/1344800/