Your C # class uses parameters with a default value that is slightly different from overloaded constructors. In any case, F # supports both overloaded constructors and default parameters.
Using the default values โโof the parameters, the code will look like this:
type SharedRegistry(?useCache: bool) = do
Now you can create an instance as follows:
let r1 = new SharedRegistry() // using the default value let r2 = new SharedRegistry(false) // specified explicitly let r3 = new SharedRegistry(useCache=false) // using named parameter
I find using named parameters a little more elegant in F #. The way it works is that the useCache parameter becomes option<bool> under the cover (this can be a problem if you want to use a class from C #)
Relatively overloaded constructors . Your F # code must be correct (see answer from kvb). In the general case, it is probably better to have at least one implicit constructor (since this allows you to automatically access the constructor parameters inside the class body, declare fields with let and implement the constructor logic with do ). The implicit constructor must be one that accepts all parameters. In some cases, you can make it private, which can be done as follows:
type SharedRegistry private (useCache: bool) = inherit PageRegistry(useCache) do
source share