Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

why to make private fields readonly in c#

f it's private and readonly , the benefit is that you can't inadvertently change it from another part of that class after it is initialized. The readonly modifier ensures the field can only be given a value during its initialization or in its class constructor.
 
PREVIOUS NEXT
Tagged: #private #fields #readonly
ADD COMMENT
Topic
Name
5+4 =