I use LINQ and return the list to my business logic level. I want to change one of the values in the list (change the star rating to an image with the number of stars).
Although counter (i) is working, the FOR loop is not working properly. The first time through it, it stops at the correct IF, but then it pops up in the ELSE statement for everything, and all values end with "star0.png". I don’t seem to be rolling through the list through ??? Thanks in advance!
for (int i = 0; i < ReviewList.Count; i++) { string serviceCode = ReviewList[i].SERVICE.SERVICE_DESC; if (serviceCode == "*") { ReviewList[i].SERVICE.SERVICE_DESC = "star1.png"; } else if (serviceCode == "**") { ReviewList[i].SERVICE.SERVICE_DESC = "star2.png"; } else if (serviceCode == "***") { ReviewList[i].SERVICE.SERVICE_DESC = "star3.png"; } else if (serviceCode == "****") { ReviewList[i].SERVICE.SERVICE_DESC = "star4.png"; } else { ReviewList[i].SERVICE.SERVICE_DESC = "star0.png"; } }
Susan source share