I have a type Bar
that defines an implicit cast operator:
public static implicit operator Bar(Foo foo)
{
return new Bar(foo.property);
}
Converting single objects works great, but now I have a List<Foo>
and I need a List<Bar>
.
I found this workaround:
List<Bar> barList = fooList.ConvertAll<Bar>(item => item);
which seems to do the trick, but it's somewhat defeating the point of an implicit cast operator if I have to apply it in this somewhat explicit sense. Is there any way to make the implicit conversion work for lists?