Skip to content

Instantly share code, notes, and snippets.

@thethomaseffect
Created October 21, 2013 15:45
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 thethomaseffect/7086037 to your computer and use it in GitHub Desktop.
Save thethomaseffect/7086037 to your computer and use it in GitHub Desktop.
Simple functional C# example
using System;
using Person = System.Tuple<string,string,int>;
namespace FunctionalCsharpExample
{
class FunctionalCSharp
{
static string CompareAge(Person a, Person b)
{
if (a.Item3 == b.Item3)
{
return "the same age as";
}
return a.Item3 > b.Item3 ? "older than" : "younger than";
}
static void Main(string[] args)
{
var person1 = new Person("Thomas", "Dublin", 23);
var person2 = new Person("John", "Sligo", 22);
Console.WriteLine(person1.Item1 + " is " + CompareAge(person1,person2) + " " + person2.Item1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment