Interactive Session #3: user input

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

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

val s : string = "howdy"

Values can be converted with the respective conversion function:

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

val pi : float = 3.1415

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

val how_many : int = 15

Single key strokes can be read using the Readkey function.

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

>

More can be found here: Environment.GetCommandLineArgs

Advertisements
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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s