Parse number and handle out parameter in C#

Category:
InterOp
Description: Parse number and handle out parameter in C#
Code:
#")>]
let InterOpSample4() =
let parse str =
match System.Decimal.TryParse(str, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture) with
| (true, r) -> Some(r)
| (false, _) -> None

printfn "%A" (parse "123")
printfn "%A" (parse "acd")

Execution Result:
Some 123M


Last edited Sep 14, 2011 at 3:06 AM by ttliu2000, version 1

Comments

No comments yet.