I am working on asp.net mvc4 and i am using razor for displaying data in my view.I am using one for loop in my view.my loop code is like below.
**@for (int i = 0; i < 5; i++)
{
if (i<(@Html.DisplayFor(m => m.ProductInfo[5].Value)))
{
<img src="../../Images/star-on.png" />
}
else
{
<img src="../../Images/star-off.png" />
}
}**
In my above for loop in if condition i am trying to bind the number like 4.But it gives error like below
operator ' ' cannot be applied to operands of type 'int' and 'system.web.mvc.mvchtmlstring'
But when i display this razor code in my view like its showing the number "4".The code is like below.
@Html.DisplayFor(m => m.ProductInfo[5].Value)
i<(@Html.DisplayFor(m => m.ProductInfo[5].Value))Why are you comparing a number to HTML? Why do you expect it to work? Is<span>greater than or equal to 6?