Sunday, March 13, 2011

Difference between ReadOnly and const keywords

Difference between ReadOnly and const keywords
Readonly fields can be initialized either in the declaration of the ReadOnly fields or in the constructor in the same class.
Const field is different from readonly.
A const field can only be initialized while declaring the field whereas A readonly field can be initialized either at the declaration or in a constructor.
A const field is a compile-time constant. The readonly field can be used for runtime constants

No comments:

Post a Comment