I am trying to create a standard .NET List<T> in F# like this:
module Csv
open System;
type Sheet () =
let rows = new List<Object>()
but I get the following error:
No constructors are available for the type
List<Object>
C:\…\Csv.fs: 6
What am I doing wrong?
As a simpler alternative to what others suggest, you can use the type named
ResizeArray<T>. This is a type alias forSystem.Collections.Generic.List<T>defined in the F# core libraries:In the compiled code,
ResizeArray<T>will be compiled down toSystem.Collections.Generic. List<T>, so if you use your library from C#, there will not be any difference.You do not have to open
System.Collections.Generic, which would hide the definition of the F#List<T>type (though this is not a big problem), and I think thatResizeArrayis a more appropriate name for the data structure anyway.