I'm currently using SyndicationFeed to extract an image from a syndication item.
Each item has a collection of links. For each link collection I want to do the following:
- check the first instance where
link.MediaType
contains an image, - if it does, return
link.Uri
else return an empty string
I wanted to do something like this:
var imageLink = image.Links.First(where( s.mediaType contains "image" && s.mediaType != null))
if (imageLink){
string imageUrl = imageLink.Uri
}
Currently I have a lot of if statements. I'm wondering if there's a cleaner way to do this.
Something like this is what you want: