I have a List defined like this :
public List<string> AttachmentURLS;
I am adding items to the list like this:
instruction.AttachmentURLS = curItem.Attributes["ows_Attachments"].Value.Split(';').ToList().Where(Attachment => !String.IsNullOrEmpty(Attachment));
But I am getting this error: Cannot implicitly convert IEnumerable to List
What am I doing wrong?
The
.ToList()
should be at last. Because in your code you perform the.ToList()
operation earlier and after that again it goes to previous state. The Where method returns an IEnumerable.The Where method returns an
IEnumerable<T>
. Try addingto the end like so:
Move the
.ToList()
to the end like thisThe Where extension method returns
IEnumerable<string>
andWhere
will work on arrays, so theToList
isn't needed after theSplit
.