public static class Program {
public record Person(String FirstName, String LastName);
public class PersonInitOnly {
public string FirstName { get; init; }
public string LastName {get; init; }
public PersonInitOnly(string firstName, string lastName) {
public override string ToString() => $"{nameof(PersonInitOnly)} {{ {nameof(FirstName)} = {FirstName}, {nameof(LastName)} = {LastName} }}";
public class Container<T> {
public T Value { get; init; }
public Container(T value) => Value = value;
public static void Main() {
var person = new Person("John", "Doe");
var otherPerson = person;
var container = new Container<Person>(person) {
Value = {FirstName = "Jane"},
Console.WriteLine(person);
Console.WriteLine(otherPerson);
var ioPerson = new PersonInitOnly("John", "Doe");
var ioContainer = new Container<PersonInitOnly>(ioPerson) {
Value = { FirstName = "Jane" },
Console.WriteLine(ioPerson);