Hide this comment

Oops, crossed post, mau got it first! So I'll show how to go backwards:

let myNewList = List<int>()

myList |> List.iter myNewList.Add

(My original post:)

You can take advantage of the fact that both List<> and string[] are usable as sequences since they implement IEnumerable<>:

let x0 = Seq.toList "asdasdads"

let xL = new List<int>()

xL.Add(1)

xL.Add(2)

xL.Add(3)

let x1 = Seq.toList xL

-Neil

By on 5/19/2010 7:27 AM ()Reply
Hide this comment

Thanks guys for the prompt answers. Be sure both will be worth for my needs.

By on 5/19/2010 8:00 AM ()Reply
Hide this comment

Use Seq.toList to convert any IEnumerable to an F# list:

let myList = new System.Collections.Generic.List<int>()

myList.Add(3)

myList.Add(6)

myList.Add(9)

let fsList = myList |> Seq.toList

By on 5/19/2010 7:23 AM ()Reply
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper

Logging in...