Convert C# to F#.

This was done with little regard for being idiomatic in F# and at times
I tried hard to retain the C# flavour into the F# code.