質問

このクラスはF#でどのように見えますか?

public class myClass : baseClass
{
    public myClass()
    {
        this.someVariable = "test";
        this.someFunction();
    }
}

これまでのところ、私は理解しました(それは正しいですか?):

type myClass = class
        inherit baseClass
        new ()= 
            this.someFunction()
end

しかし、「これ」が定義されていないと書かれているので、somefunction()に電話するのに苦労しています

役に立ちましたか?

解決

コードを翻訳する1つの方法は次のとおりです。

type baseClass() =
    member this.someFunction() = printf "hello world\n"

type myClass() as this =
    inherit baseClass()
    let mutable someVariable = "test"
    do this.someFunction()
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top