To declare a variable in the View using Razor syntax, we need to first create a code block by using @{ and } and then we can use the same syntax we use in the C#.
@{ var fileName = "dotnetfunda"; var a = 20; var b = 30; var physicalPath = @"C:\program files"; var doubleQuote = @"This is ""dotnetfunda.com"""; string myName = "ITFunda"; var sum = "60"; }
In the above code, notice that we have created the Code block and then start writing C# syntax to declare and assign the variables.
Views: 54828 | Post Order: 10