Variables in C#

To use variables, you have to declare them. This means that you have to assign them a name and a type . Once you have declared variables, you can use them as storage units for the type of data that you declared them to hold.
 
C# syntax for declaring variables merely specifies the type and variable name:

< type > < name > ;

If you try to use a variable that hasn ’ t been declared, your code won ’ t compile, but in this case the compiler tells you exactly what the problem is, so this isn ’ t really a disastrous error. Trying to use a variable without assigning it a value also causes an error, but, again, the compiler detects this.
 
There is an almost infinite number of types that you can use. This is because you can define your own types to hold whatever convoluted data you like. Having said this, though, there are certain types of data that just about everyone will need to use at some point or another, such as a variable that stores a number. Therefore, you should be aware of several simple, predefined types.