5 ms·
Auto-properties can be public read, private set. So really, it looks like: namespace MyCompany.MyProduct { public class Person { publ
by DanielStraight 15y ago
Auto-properties can be public read, private set. So really, it looks like:
namespace MyCompany.MyProduct
{
public class Person
{
public Person(string name, int age)
{
Name = name;
Age = age;
}
public string Name { get; private set; }
public int Age { get; private set; }
}
}
I suppose it's not technically immutable, but you can just refrain from setting anywhere else inside the class.
- balakk 15y agoThe author responds to that point in the blog's comments section.