F# - Defining an extension method for generic arrays

by Gregor Uhlenheuer on August 16, 2012

Lately I wanted to write a small extension method for the Array class in F#. What would be a pretty simple task in C# appears to be a bit more tricky in F#.

After trying a few things without any success I found a solution on StackOverflow that I want to share with you.

Basically this is what it has to look like in F#:

The trick is to use the backticks notation to define the array class. As stated in the mentioned post you can extend via the IList<_> generic interface as well:

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