Skip to content

Instantly share code, notes, and snippets.

@Horusiath
Created July 6, 2014 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Horusiath/36ab3ef3f1989f8b46ce to your computer and use it in GitHub Desktop.
Save Horusiath/36ab3ef3f1989f8b46ce to your computer and use it in GitHub Desktop.
F#/C# OO syntax comparison
// class inheritance - C#
public abstract class Ancestor {}
public class Descendant: Ancestor, IDisposable
{
public void Dispose() {}
public virtual void MyVirt() {}
}
// class inheritance - F#
[<AbstractClass>]
type Ancestor() = class end
type Descendant() =
inherit Ancestor()
interface IDisposable with
member x.Dispose() = ()
abstract member MyVirt: unit -> unit
default x.MyVirt() = ()
// properties - C#
public string MyProp { get; set }
// properties - F#
member val MyProp = "" with get, set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment