3 ms·
It is actually the equivalent of a private backing field that is marked readonly. public class Person{ private readonly string name; public Pers
by briHass 11y ago
It is actually the equivalent of a private backing field that is marked readonly.
public class Person{
private readonly string name;
public Person(string name){
this.name = name;
}
}
It's syntactical sugar that shaves a few lines of code off, particularly if you aren't setting values from parameters in the constructor and just want readonly values that are inherent to the class.