C # Programming Fundamentals-Constants
Constants are immutable values that are known at compile time and do not change during the lifetime of the program. Constants are declared using the const modifier.
Constants must be initialized at declaration time, and the type of the constant must be one of the following types: sbyte/byte/short/ushort/int/uint/long/ulong/char/float/double/decimal/bool/string/ Enumeration type/reference type.
When the compiler encounters a constant modifier in C # source code, the literal value is replaced directly in the intermediate language code it generates. Because there is no variable address associated with a constant at run time, the Const field cannot be passed by reference and cannot appear as the left-hand value in the expression.
Constants can be marked as public/private/protected/internal or protected internal. These access modifiers define how the user accesses constants.
Constants can be accessed as static fields, but constants are not declared with the static keyword.
C # Programming Fundamentals-Constants