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" ;

See Also
Related

Access Modifiers

Documentation

Constants

Add to Slack

< Parse   |   Pointers and References >

© 2018 SyntaxDB. All Rights Reserved.