Introduction
In this article we will see how to create a variable and get its value.
Step 1
Create a MVC project using the "Empty" template.
Right-click on "Controllers" and select "Add" >> "Controller…".
Step 2
Select "MVC 5 Controller - Empty" to add an empty controller.
Click on the "Add" button.
Step 3
Name the controller as in the following:
Step 4
This will create an action method that returns a view.
Step 5
Now we need to create a view.
Right-click on "Index" and select "Add View...".
Step 6
Name the view and select "Empty (without model)" as the template.
Click on the "Add" button.
Step 7
As you can see in the following code snippet, we create a variable using @ in the view, store some value in variable and get the value inside the same view.
Step 8
Run the project and you get the value stored in the variable.
<< Day 3 >> Day 5