Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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