interface IMyInterface
{
int MyProperty { get; set; }
}
The way to define this in F# is:
type IMyInterface= interface
abstract MyProperty : int with get, set
end
The interesting thing about F# interface implementation is F# use explicit interface implementation. So if the interface definition does not have "set", then your class implementation will have to change if the class still need both "get" and "set".
The interesting thing about F# interface implementation is F# use explicit interface implementation. So if the interface definition does not have "set", then your class implementation will have to change if the class still need both "get" and "set".
type IMyInterface= interface
abstract MyProperty : int with get
end
class implementation:
type MyClass() =
interface IMyInterface with
member this.MyProperty with get() = ...
member this.MyProperty with set(..) = ...
class implementation:
type MyClass() =
interface IMyInterface with
member this.MyProperty with get() = ...
member this.MyProperty with set(..) = ...
No comments:
Post a Comment