Lambda ForEach () Index position
This is somewhat asp.net MVC linked just for example, but I was hoping to achieve something like this:
new SelectList(ViewData.Model.Formats.ToList().ForEach(x => index + " - " + x.Name), "ID", "Name");
Basically trying to be smart and return "index" as a number 1 - n, where n is the number of items in the list ViewData.Model.Formats
, so my picklist is prefixed in every entry. Any easy way to do this, or am I looking at creating a new list with this lambda trick adding and breaking away?
+1
source to share