I have written an F# module that has a list inside:
module MyModule
type X =
{
valuex : float32
}
let
The FSharpListlist
type) doesn't implement IList
, because it doesn't make sense.
IList
is for accessing and modifying collections that can be accessed by index, which list
is not. To use it from C#, you can either use the type explicitly:
FSharpList l = MyModule.l;
var l = MyModule.l; // the same as above
Or you can use the fact that it implements IEnumerable
:
IEnumerable l = MyModule.l;
Or, if you do need IList
, you can use LINQ's ToList()
, as Ani suggested:
IList l = MyModule.l.ToList();
But you have to remember that F# list is immutable and so there is no way to modify it.