Const keywords are used to modify the declaration of fields or local variables. It specifies that the value of the field or local variable cannot be modified. Constant statement introduces one or more constants of a given type. This statement is:
[attributes] [Modifiers] Const Type Declarators;
Remarks constant declarations can declare multiple constants, for example: public const double x = 1.0, y = 2.0, z = 3.0; not allowed to use Static modifiers in a constant declaration. Constants can participate in constant expressions, for example: public const INT C1 = 5.0; public const INT C2 = C1 100;
READONLY keyword
Const keywords.
The Const field can only initialize in the declaration of this field.
The readonly field can be initialized in a declaration or constructor. Therefore, according to the constructor used,
The READONLY field may have different values. In addition,
The const field is the time of compile, and
The READONLY field can be used to run the time, as shown in the following example:
Public static readonly uint l1 = (uint) DateTime.now.ticks;