locked
Console in F# RRS feed

  • Question

  • The code below compiles but I can not see any console window to interact. 

    What should i do?

    open System

        

    let main()=
        Console.WriteLine ("what is your name?")
        let name = Console.ReadLine()
        Console.WriteLine("Hello Mr. ",name);;

    val main : unit -> unit


    DaFonseca

    Thursday, June 20, 2013 12:20 PM

Answers

  • After you send your code in F# interactive, the FSI environment contains only definition of your main function.

    You have to call this main function explicitly: main()

    Console input/output will be redirected to F# interactive window - you'll see greetings there, also you'll be able to enter your name in this window also.  

    let main()= Console.WriteLine ("what is your name?") let name = Console.ReadLine() Console.WriteLine("Hello Mr. {0}", name) // you probably wanted to show entered name here

    main();; // this is line that will call your function



    Petr

    Thursday, June 20, 2013 12:35 PM