Language
Version: 5
Categories
-
User Program Communication
-
Variables
-
Control Flow
-
Object Oriented Programming
-
Strings
Variables
Constants in C#
Constants are used to declare an identifier whose associated value cannot be altered during the execution of the program.
Syntax
modifier const variableType variableName = value;
Notes
variableType is the type (boolean, float, int, void, etc.) of the specified variable.
Constants cannot be static.
Example
public const int AGE = 20;
private const string VEHICLE = "Convertible" ;