F# – defining explicit operator in F#

Update 2012/08/23: Thanks for the sug­ges­tion from Jizugu in the com­ments, I’ve updat­ed the post to show you his approach to call­ing the explic­it oper­a­tor in a clean and ele­gant way.


In C#, you can define an explic­it oper­a­tor for your type using the explic­it key­word:


You can define an explic­it oper­a­tor like the below and use a cus­tom oper­a­tor to make invok­ing the explic­it oper­a­tor in an ele­gant way rather than hav­ing to call the sta­t­ic Person.op_Explicit method:

Liked this post? Why not support me on Patreon and help me get rid of the ads!