简体   繁体   中英

F#, the value or constructor 'List' is not defined

I am copying this code out of a book on F#. The compiler is supposed to create a generic function.

Instead, I am getting an error

"FS0039: The value or constructor 'List' is not defined."

Why?

let createList(first, second) = 
    let output = List()
    output.Add(first)
    output.Add(second)
    output

// expected output below
// val createList : first:'a * second:'a -> List<'a>

I added this line to the script

open System.Collections.Generic 

unlike C#, Visual Studio F# isn't good at telling you when you need to add an open statement like this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM