F#继承接口

Mar*_*rta 2 f# c#-to-f#

我在F#中有以下类继承了Microsoft.AspNet.Identity.IIdentityValidator接口:

type MyValidation() =
    inherit IIdentityValidator<string> with
        member x.ValidateAsync (value:string) : Task<IdentityResult> =
        .....
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

 This 'inherit' declaration specifies the inherited type but no arguments. Consider supplying arguments, e.g. 'inherit BaseType(args)'.
Run Code Online (Sandbox Code Playgroud)

为什么以及如何解决?

kno*_*cte 5

关键字inherit仅适用于派生类.你需要使用interface:

type MyValidation() =
    interface IIdentityValidator<string> with
        member x.ValidateAsync (value:string) : Task<IdentityResult> =
            ...
Run Code Online (Sandbox Code Playgroud)