0

I have two code which are giving the same output. what would be the difference here if I use Model.ItemPrice and @Model.ItemPrice? both give same result.

@if(Model.ItemPrice == "1300")
{
   @Model.ItemPrice   
}

@if(@Model.ItemPrice == "1300")
{
 @Model.ItemPrice   
}
Kurkula
  • 6,945
  • 26
  • 108
  • 186

2 Answers2

2

There's no difference between using Model and @Model in your @if(...) statement.

@ starts a code section or outputs a variable in Razor syntax, and once in code (so in your @if(...)), it is a character to escape reserved words as defined in the C# syntax.

For the former see What does the “@” in ASP MVC mean/do?, the latter is explained in What's the use/meaning of the @ character in variable names in C#?.

Community
  • 1
  • 1
CodeCaster
  • 139,522
  • 20
  • 204
  • 252
2

none. the @ is only used as an escape to put Razor code in the view.