Read Only Fields
When the value of a field is only visible outside the class it is called a read only property.
The value of the field can only be changed inside the class.
public class Animal
private readonly int _Age;
The readonly keyword is used to declare a constant that can be defined in its declaration or at run-time in the constructor.
This value cannot be changed after the class has been created.
The const keyword is used to declare a constant that must be defined in its declaration.
A read only field that contains an object can have its properties modified at run-time
A private set property can be called after the class has been created.
© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext