Wednesday, July 23, 2014

CLR via C# - CHAPTER 7 Constants and Fields

Constants and Fields
Constants
When code refers to a constant symbol, compilers look up the symbol in the metadata of the assembly that defines the constant, extract the constant’s value, and embed the value in the emitted Intermediate Language (IL) code.

Fields
However, readonly fields can be written to only within a constructor method (which is called only once, when an object is first created). 

When a field is of a reference type and the field is marked as readonly, it is the reference that is immutable, not the object that the field refers to.

































































No comments:

Post a Comment