views:

141

answers:

1

Is there a built-in method to convert the .NET List<> into the F# list?

+9  A: 

Try List.ofSeq in the Microsoft.FSharp.Collections namespace.

#                     List.ofSeq : seq<'T> -> 'T list

It's not specifically for System.Collections.Generic.List<T>, but for IEnumerable<T> (seq<'T> in F#) types in general, so it should still work.

(It's also not strictly built into the F# language, but neither is List<T> built into C# or VB.NET. Those are all part of the respective standard libraries.)

stakx
I also noticed with the 2.0 compiler type inference the List<Something> on the right hand side shows up as a seq (or IEnumerable) on the left hand side. Pretty smart of those guys (+1)
tyndall