C# series 1.9 : Constant - ponda

Breaking

7/08/2017

C# series 1.9 : Constant

Constants

Constants store a value that cannot be changed from their initial assignment. To declare a constant, use the const modifier.

For example :
const double PI = 3.14;

The value of const PI cannot be changed during program execution.
For example, an assignment statement later in the program will cause an error.

const double PI = 3.14;
PI = 8; // error

Constants must be initialized with a value when declared.

No comments:

Post a Comment