F# doesn't do implicit casting like C#. So even though System.Collections.Generic.List<'T>
implements the ICollection
interface, you can't directly set some ICollection
-typed property to an instance of System.Collections.Generic.List<'T>
.
The fix is easy though -- all you need to do is add an explicit upcast to ICollection
to your ResizeArray<'T>
or System.Collections.Generic.List<'T>
before assigning it:
// Make sure to add an 'open' declaration for System.Collections.Generic
this.field.Collection1 = (recoveries :> ICollection)
or
this.field.Collection1 = (ResizeArray<Recoveries>() :> ICollection)