Backwards compatibility is hard
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
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}"; | |
} | |
} | |
} |
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; | |
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