For the complete documentation index, see llms.txt. This page is also available as Markdown.
tryParse
Namespace: FsToolkit.ErrorHandling
tryParse tries to parse a string value into a specified type using the type's TryParse method. Returns Some value if parsing succeeds, or None if it fails.
Note: This function is not available when using Fable (JavaScript/Python compilation).
Function Signature
string ->^value option
where ^value has a static member TryParse: string * byref<^value> -> bool.
Examples
Example 1 — Parsing an integer
letresult:int option = Option.tryParse "42"// Some 42
Example 2 — Parsing failure
letresult:int option = Option.tryParse "not a number"// None