Last active
March 1, 2020 03:10
-
-
Save jakewitcher/b1e4e1acaceb2e6495811654968dfae4 to your computer and use it in GitHub Desktop.
Introduction to Type Classes for .NET Developers, Number interface
This file contains 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
public interface Number<T> | |
{ | |
T Add(T a, T b); | |
T Subtract(T a, T b); | |
} | |
public class Integer : Number<int> | |
{ | |
public int Add(int a, int b) => a + b; | |
public int Subtract(int a, int b) => a - b; | |
} | |
public class Double : Number<double> | |
{ | |
public double Add(double a, double b) => a + b; | |
public double Subtract(double a, double b) => a - b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment