简体   繁体   中英

How do I stop the console window from closing in Visual studio 2019?

I have had this problem for a while but I haven't used Visual studio in ages. But now I just want to solve this issue.

I'm following a F# course at school and i try to follow along with my teachers coding session. This is the code

module Program

open System

let incr = 
  fun x -> 
    x + 1 

[<EntryPoint>]
let main argv =
  let res = incr 5 
    printfn "My result is %d and I print a random number %d" res 5
    0

When I hit F5 or press start the window pops up real quick, no output is shown and it closes instantly. I was reading on other similar posts that you had to disable

tools>options>debugging>Automatically close the console when debugging stops

But it was already unchecked, then I read about that you have to set "subsystem to console" but I tried to look this up but I couldn't find anything about this that I could make sense off.

I'm just trying to do my homework and I really want to fix this problem so I can start using Visual studio again.

If possible, make the project type you create an F# .NET Core console app (which should be the first F# template in the New Project dialog). This uses a different system under the hood where the console window stays open and is re-used by subsequent runs.

Also a possibility, if your application is just for exploring. For production apps I'd go for Phillip Carter's answer.

[<EntryPoint>]
let main argv =
    ...
    Console.ReadKey() |> ignore
    0

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