Skip to content

Instantly share code, notes, and snippets.

@markrendle
Created June 3, 2015 20:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save markrendle/13c84348970224975837 to your computer and use it in GitHub Desktop.
Backwards compatibility is hard
namespace PersonApp
{
public class Person
{
public Person()
{
}
private Person(string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
}
public string FirstName { get; }
public string LastName { get; }
// Be nice if C# could cope with Properties and Methods having the same name...
// Let's protest by violating naming conventions :)
public Person firstName(string firstName)
{
return new Person(firstName, LastName);
}
public Person lastName(string lastName)
{
return new Person(FirstName, lastName);
}
public override string ToString()
{
return $"{FirstName} {LastName}";
}
}
}
using System;
namespace PersonApp
{
public class Program
{
public static void Main(string[] args)
{
var person = new Person().firstName("Jon").lastName("Skeet");
Console.WriteLine(person.ToString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment