Setting up the markup for this project
Here, we'll create a project. Start with the simple HTML markup shown in the following screenshot:

Figure 6.10.1: The simple HTML markup for our project
Creating the product class
Now, go to the Solution
Explorer, right-click on the name of the website, select Add
, and then click on Class
. Name the class Product
and click on OK
. When the Visual Studio message comes up, click on Yes
.
So the relevant portion of the initial Product
class code looks as shown in the following screenshot, which is sufficient for our purposes:

Figure 6.10.2: The initial Product class code
What's true about every product is that you have a price, a name, and so on. For our purposes, enter the following below the open curly brace under public class Product
:
private decimal price;
There you go! Of course, the only thing we'll do within the body of the constructor is type the following:
price = pri;
This line is used to set the value of the instance variable. Now let's make a virtual
function...