Skip to content

Instantly share code, notes, and snippets.

@floh1695
Created April 27, 2018 01:15
Show Gist options
  • Save floh1695/68bf1de8a8db9039864e96da28f61744 to your computer and use it in GitHub Desktop.
Save floh1695/68bf1de8a8db9039864e96da28f61744 to your computer and use it in GitHub Desktop.
using System;
class Person
{
public string FirstName;
public string LastName;
public static Person operator +(Person leftPerson, Person rightPerson)
{
return new Person
{
FirstName = rightPerson.FirstName,
LastName = leftPerson.LastName
};
}
public override string ToString()
{
return $"{FirstName} {LastName}";
}
}
class Program
{
static void Main(string[] args)
{
var dad = new Person
{
FirstName = "Joe",
LastName = "Joesson"
};
var mom = new Person
{
FirstName = "Eve",
LastName = "Evesson"
};
var child = dad + mom;
Console.WriteLine($"{dad} and {mom} had a child named {child} together");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment