Interactive Session #3: user input

Reading input from the console is performed using the Readline function.

> open System;;
> let s = Console.ReadLine();;

val s : string = "howdy"

Values can be converted with the respective conversion function:

> let pi = float(Console.ReadLine());;

val pi : float = 3.1415

> let how_many = int(Console.ReadLine());;

val how_many : int = 15

Single key strokes can be read using the Readkey function.

> let c = Console.ReadKey();;
val c : ConsoleKeyInfo = System.ConsoleKeyInfo


More can be found here: Environment.GetCommandLineArgs

This entry was posted in Getting Started. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s