AllTheTimeWorld.com

csharp variablesVariables

Variables

Variable definition, types, and how to declare variables

Variables

Variable definition, types, and how to declare variables

A program that always displays the same message can get a bit boring. Most programs get some information, do some calculations, and then display the results of the calculations.

Information is stored in memory as variables. Variables can vary, or change. Before a variable can be used, it must be declared. To declare a variable, first decide what type of information you want to store:

These are the simple types in C#:

For the purposes of this course, the following will be used:

In addition to the types listed above you will also sometimes declare variables to be one of the special types built-in to C#:

 Color myFavColor = Color.PeachPuff;