F# 实现基础 class

F# Implement base class

我是 F# 的新手,我想创建一个 F# Forms 应用程序。但我现在遇到的问题是,我不知道如何实现一个基础 class。在 C# 中我会那样做

namespace Test_Form
{
    public class Form1 : Form
    {
        public Form1()
        {

        }
    }
}

但是我如何在 F# 中创建它,以便我的表单是一个模块而不是一个类型

我已经试过了

open System
open System.Windows.Forms

type Form1() = 
    inherit Form()

但这会导致

public class Form1 : Form
{
    public Form1() : this()
    {
    }
}

在 C# 中使用构造方法的地方

public class Form1 : Form
{
    public Form1()
    {
        // Do stuff
    }
}

在 F# 中,引用 the docs

The do-bindings section includes code to be executed upon object construction.

你会

type Form1() =
    inherit Form()

    do // stuff

例如:

type Form1() as this =
    inherit Form()

    do this.Click.Add(fun args -> printfn "%s" <| args.ToString())