In C#, a const has to be initialized when it is declared. But, many times we put configuration details in XML files which the application needs to read once and not change for the life of the application. One can use “readonly” to achieve just this.
readonly fields can either be initialized at declaration or in a constructor. That's it. It cannot be modified anywhere else.
0 comments
Hide comments