目录

if /then statement

if/then语句由一个布尔表达式后跟一个或多个语句组成。

语法 (Syntax)

F#中的if/then结构具有以下语法 -

(* simple if *)
if expr then
   expr

流程图

如果那么声明

例子 (Example)

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 20
Value of a is: 10
↑回到顶部↑
WIKI教程 @2018