本文概述
- F#元组声明
- F#元组示例
句法:
(element, ... , element)
F#元组声明在F#中有多种创建元组的方法。下面给出一些。
(50, 100)// Two integer values
(Hello, FSharp)// Two string values
(a, b)// Two variables
(50, 100, FSharp, 10.50) // Different types values
(a+b, a*b)// Expressions
let (a, b) = (1, FSharp)// Let binding
F#元组示例
let (id, name) = (1, "Fsharp")
printfn "%d" id
printfn "%s" name
输出:
1
FSharp