if/then语句由一个布尔表达式后跟一个或多个语句组成。
if /then - 语法
F#中的if/then构造具有以下语法-
(* simple if *) if expr then expr
if /then - 流程图

if /then - 示例
let a : int32=10 (* check the boolean condition using if statement *) if (a < 20) then printfn "a is less than 20\n" printfn "Value of a is: %d" a
当您编译并执行程序时,它会生成以下输出-
a is less than 20Value of a is: 10