如何以F#语言暂停控制台
问题描述:
请告诉我在F#中运行程序时如何暂停控制台窗口.
Please tell me how I can pause the console window when running the program in F#.
open System
let myList = [0..9]
let myFunction =
for n in myList do
Console.WriteLine(n)
myFunction
答
您可能考虑将暂停函数包装在编译器指令中,因为您可能不希望在发布代码中产生相同的效果.
You may consider to wrap the pause function in compiler directives, since you probably don't want to have the same effect in release code.
(* your code here *)
#if DEBUG
System.Console.ReadKey(true) |> ignore
#endif