Friday, May 22, 2015

Difference between Read-only, Constant, Static members



Read-only: Can be initialized with the instance creation. Varies from object to object. The readonly field can be used for run-time constants, as in this line: public static readonly uint l1 = (uint)DateTime.Now.Ticks;


Constant: Values are initialized at the time of declaration and cannot be changed future. Const field is a compile-time constant.


Static: All objects hold the same value that is initialized.

No comments:

Post a Comment