[英]How to define a F# abstract member with empty type-signature
According to this page , all abstract members of a class must have a type-signature
. 根据此页面 ,类的所有抽象成员必须具有type-signature
。 But I want to define a abstract class that has void input parameter and void return type. 但是我想定义一个具有无效输入参数和无效返回类型的抽象类。 And void
is not valid keyword in this context. 在这种情况下, void
不是有效的关键字。
In F#, you typically use the unit
type where you would use the void
keyword in C#. 在F#中,通常使用unit
类型,而在C#中将使用void
关键字。 So an example of what you're looking for would be: 因此,您正在寻找的示例是:
[<AbstractClass>]
type MyAbstractClass() =
abstract MyMethod : unit -> unit
type MyDerivedClass() =
inherit MyAbstractClass()
override this.MyMethod() = printf "Do something here..."
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.