Reputation: 12137
With the following C# code
var MyList = new List<MyClass>();
SomeFSharpFunc(MyList);
on the F# side:
let SomeFSharpFunc (MyList: ???What do I put here so I know it's a list) =
I don't know to how express that the incoming parameter is a list.
Also, do I need to duplicate the C# class as a F# type?
Upvotes: 1
Views: 122
Reputation: 170919
You can just use
open System
let SomeFSharpFunc (MyList: System.Collections.Generic.List<MyClass>) = ...
but you should consider using seq<MyClass>
instead (which is equivalent to IEnumerable<MyClass>
) if you don't need full power of System.Collections.Generic.List
, especially since in F# "list" generally refers to a very different data structure.
See also Converting between C# List and F# List.
Also, do I need to duplicate the C# class as a F# type?
No.
Upvotes: 4