Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a custom F# operator in C#?

I've stumbled upon the fact that it's possible to define custom operators in F#. Also, I believe it's possible to reuse F# code in C#.

Is it possible to create a custom operator in F#, reference the project in C# and then reuse the operator in C#? For example, lets say I were to define the .? operator as something in F#, could I then somehow reuse it in my C# projects?

like image 255
EvilBeer Avatar asked Apr 08 '14 15:04

EvilBeer


People also ask

How do I use a custom field plugin in WordPress?

Simply create a new post or edit an existing one. Go to the custom fields meta box and select your custom field from the drop-down menu and enter its value. Click on the 'Add Custom Field' button to save your changes and then publish or update your post.

Is advanced custom fields free?

- [Instructor] There are two versions of Advanced Custom Fields, a free version and a pro version. The free version includes most of the functionality of the plug-in and we'll be using that for the majority of the course.


1 Answers

Custom defined operators can be used just fine from C#. The names are auto-generated and are of the form op_<symbol...> (see Overloaded Operator Names on MSDN).

For example

let (|?) a b = ...

would be available as op_BarQmark.

However, as Mau points out in his comment, you will only be able to use it from C# as a method, not an operator.

like image 52
Daniel Avatar answered Sep 28 '22 08:09

Daniel