Maha

Maha

  • NA
  • 0
  • 324.8k

NP80 compile time & runtime

Feb 12 2008 2:21 AM

Hi Guys

 

NP80 compile time & runtime

 

Following paragraph I got from a book. It is explaining about Read-Only field. Please explain the different between the compile time and the runtime.

 

Thank you

 

Static Read-Only Fields

Static read-only fields are also permissible. This can be helpful if you wish to create a

number of constant values bound to a given class. In this light, “readonly” seems to be a close cousin to the “const” keyword.

 

The difference is that the value assigned to “const” must be resolved at compile time, and therefore cannot be assigned a new type instance (as this is computed at runtime). The value of read-only static fields, however, may be computed at runtime, and therefore may be assigned type instances as well as simply data types (int, float, string, etc.).


Answers (7)