Out reference parameters in F#

by Gregor Uhlenheuer on December 3, 2012

Lately I wanted to implement a class that derives from DynamicObject (in the System.Dynamic namespace) and therefore I had to override the methods TrySetMember and TryGetMember. Especially the latter one forced me to look up on reference parameters in F#.

The method signature of TryGetMember looks like the following (in C# syntax):

In F# you have to declare the result parameter as a reference type with byref:

I am not quite sure if the [<Out>] parameter attribute is really necessary since my project compiled just fine without it as well.

This post is tagged with f#, .net and programming