I have an implicit conversion method in one of my classes.
public static implicit operator MobileTag(DetailGroup dg)
{
return new MobileTag { Id = dg.ID, Name = dg.Name, Answers = dg.Details };
}
This works just fine with a List if I foreach through it:
foreach (var tag in tagsThisEvent)
{
ev.EventTags.Add(tag); // lookin' good !!
}
But then if I use the generic Linq Cast method I get an InvalidCastException:
ev.EventTags = tagsThisEvent.Cast<MobileTag>().ToList(); // ftl !!
I can't F11 into it to see what it is balking on. Any suggestions?
When is it okay to use List.Cast().ToList() ??