Skip to content

Instantly share code, notes, and snippets.

@blair55
Last active December 18, 2015 04:29
Show Gist options
  • Save blair55/5725824 to your computer and use it in GitHub Desktop.
Save blair55/5725824 to your computer and use it in GitHub Desktop.
Implement a C# Interface in F#
namespace Domain
{
public interface IMyInterface
{
string MyProperty { get; set; }
void PerformAction();
decimal MethodWithParameters(decimal a, int b);
}
}
namespace Functional
open Domain
module MyModule =
type MyImplementation() =
let mutable TheVal = ""
let DoFunction =
printfn "hello"
()
let DivideValues a b =
a / decimal b
interface IMyInterface with
member this.MyProperty with get() = TheVal
member this.MyProperty with set(value:string) = TheVal <- value
member this.PerformAction() = DoFunction
member this.MethodWithParameters (a, b) =
DivideValues (a:decimal) (b:int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment