SHARE
TWEET

Untitled

a guest Oct 21st, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let inline tryParse<'a when 'a: (static member TryParse: string * byref<'a> -> bool)> x =
  2.     let mutable res = Unchecked.defaultof<'a>
  3.     if (^a: (static member TryParse: string * byref<'a> -> bool) (x, &res))
  4.     then Some res
  5.     else None
  6.  
  7. let a = tryParse<int>("19")
  8. let b = tryParse<Guid>("4A9FA193-26D6-4D21-8610-02B060D43744")
  9. let c = tryParse<DateTimeOffset>("ddd")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top