I\'m working with a library created in C#. I\'ve been working on porting some code to F# but must use quite a few underlying types from the C# lib.
One piece of code
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)