Created
July 6, 2014 17:24
-
-
Save Horusiath/36ab3ef3f1989f8b46ce to your computer and use it in GitHub Desktop.
F#/C# OO syntax comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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