Accessing an F# list from inside C# code

前端 未结 2 1125
囚心锁ツ
囚心锁ツ 2021-01-12 22:20

I have written an F# module that has a list inside:

module MyModule
type X = 
    {
        valuex : float32
    }
let         


        
2条回答
  •  春和景丽
    2021-01-12 23:00

    As simple as:

    IList list = MyModule.l.ToList();
    

    The reason you need the conversion method rather than a cast / implicit conversion is because an FSharpList implements IEnumerable but not IList since it represents an immutable linked-list.

    Note that you'll have to include FSharp.Core as a reference in your C# project.

提交回复
热议问题