300x250 AD TOP

helooo
Tagged under:

Varibles & Constants



1.Variables:

Variables represent storage locations. Every variable has a type that determines what values can be stored in the variable.

C# is a type-safe language, and the C# compiler guarantees that values stored in variables are always of 
the appropriate type. 


int interestRate = 5; //Declare the variable and initialize it to 5

interestRate = 10; // variable now equals 10

interestRate = 20; // variable now equals 20


2.Constant:

A constant is similar to a variable in that it provides a named location in memory to store a data value.
Constants differ in one significant way in that once a value has been assigned to a constant it cannot subsequently be changed.


const int interestRate = 10;

const int interestRate; // Invalid - a const must be initialized at creation time