public sealed class User(string name, int age) {
// Notice we've added two readonly fields back in:
readonly string name = name;
readonly int age = age;
public void PrintNameAndAge() {
Console.WriteLine($"User name: {name}, Age: {age}");
}
public void PrintNameAllCapsIfOld(int oldThreshold) {
if (age >= oldThreshold) {
name = name.ToUpperInvariant(); // This line no longer compiles
}
Console.WriteLine(name);
}
}