I'm new to F# and I wanted to create an F# Forms Application. But the Problem that I have at the moment, is that I don't know how to implement a base class. In C# I would do it like that
namespace Test_Form
{
public class Form1 : Form
{
public Form1()
{
}
}
}
But how do I make it in F# so that my Forms is a module and not a type
I already tryed
open System
open System.Windows.Forms
type Form1() =
inherit Form()
but that would result in
public class Form1 : Form
{
public Form1() : this()
{
}
}
Where you would use the constructor method in C#
public class Form1 : Form
{
public Form1()
{
// Do stuff
}
}
In F#, quoting the docs ,
The do-bindings section includes code to be executed upon object construction.
you would
type Form1() =
inherit Form()
do // stuff
For example:
type Form1() as this =
inherit Form()
do this.Click.Add(fun args -> printfn "%s" <| args.ToString())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.