I have an F # class that comes from a .net class with several constructors. To expose them all, I implement a type without a main constructor. Now I would like to add a static field. How to initialize a static field? Consider this:
type MyType = inherit DotNetType [<DefaultValue>] static val mutable private myStatic : int new () = { inherit DotNetType() } new (someArg:string) = { inherit DotNetType(someArg) }
Now, how do I initialize the βmyStaticβ field in a way that runs exactly once if this type is used, and not at all if this type is never used? Essentially, I need the equivalent of a block of static C # constructors.
f # c # -to-f #
Bruno bozza
source share