What are the difference between Readonly instance fields
and Static readonly fields
?
And how can we implement the
Static readonly fields
by Access Modifiers?
What are the difference between Readonly instance fields
and Static readonly fields
?
And how can we implement the
Static readonly fields
by Access Modifiers?
The main difference between Readonly instance fields and Static Readonly fields is that Readonly are evaluated when instance is created and Must have set value by the time constructor exits. whereas, Static readonly fields are evaluated when code execution hits class reference (i.e.: new instance is created or static method is executed) and Must have evaluated value by the time static constructor is done