Created
April 27, 2018 01:15
-
-
Save floh1695/68bf1de8a8db9039864e96da28f61744 to your computer and use it in GitHub Desktop.
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
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