Console Module
Hosted interpreter permissions: Console.writeLine requires IO. Console.readLine requires both IO and Interactive. These checks do not apply to CLI execution or compilation. See Host permissions.
Use Console to read and write text.
Console.writeLine : string -> unit
IO
Writes one line of text to standard output.
Console.writeLine "hello"
Console.writeLine $"args={Env.Arguments}"
Console.readLine : unit -> string option
IO
Interactive
Reads one line from standard input.
Returns None on end-of-input.
match Console.readLine () with
| Some text -> Console.writeLine $"echo: {text}"
| None -> Console.writeLine "no input"
Notes
Console.writeLineaccepts astring, so convert non-string values explicitly or use string interpolation.Console.readLineis a zero-argument function and should be called asConsole.readLine ().Console.readLinereturningNoneusually means stdin is exhausted or unavailable.- Console I/O is provided by the host runtime, not by the pure language core.
Example
Console.writeLine "What is your name?"
let greeting =
match Console.readLine () with
| Some name -> $"Hello {name}"
| None -> "Hello"
Console.writeLine greeting