I have a List<string> myList like shown below:
widget1
widget2
widget3
widget4
I’d like to show this on my web page like the following
widget1 | widget3 | widget4
Let’s just say if the string is “widget2” leave it out.
is there a way to do this with a linq statement?
<div>
<% myList.ForEach(x => Response.Write(Html.ActionLink(x.Name,"ActionMethod"))); %>
</div>
i know i’m asking too much but i thought i’d try.
You could do something like this:
Then just modify the where statement to fit your needs. I guess it is a matter of preference, but I dislike to use Response.Write in views, and I try to avoid the ForEach() method because it doesn’t work on plain IEnumerables.