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?
You won't find information or content that you deleted because we delete that content from our servers. Keep in mind: The categories of data we receive, collect, and save may change over time. Learn more about your Facebook data in our Privacy Policy.
As simple as:
IList<MyModule.X> list = MyModule.l.ToList();
The reason you need the conversion method rather than a cast / implicit conversion is because an FSharpList<T>
implements IEnumerable<T>
but not IList<T>
since it represents an immutable linked-list.
Note that you'll have to include FSharp.Core
as a reference in your C# project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With