Difference between static, readonly, and constant in C# (part 3)



const:



🔸 Declared using the const keyword. By default a const is static that cannot be changed.



🔸 Only the class level fields or variables can be constant.



🔸 The constant fields must be initialized at the time of declaration. Therefore, const variables are used for compile-time constants.



🔸 Constant variables cannot be modified after declaration.



🔸 Const members can be accessed using ClassName.ConstVariableName, but cannot be accessed using object.