Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.