I have written an F# module that has a list inside:
module MyModule
type X =
{
valuex : float32
}
let l = [ for i in 1 .. 10 -> {valuex = 3.3f}]
Now from a C# class I’m trying to access the previously defined list, but I don’t know how converting it:
... list = MyModule.l ; //here's my problem
I’d need something like:
IList<X> list = MyModule.l;
How can I achieve that?
As simple as:
The reason you need the conversion method rather than a cast / implicit conversion is because an
FSharpList<T>implementsIEnumerable<T>but notIList<T>since it represents an immutable linked-list.Note that you’ll have to include
FSharp.Coreas a reference in your C# project.