Chapter 2. Primitive Types and Variables

Chapter 2. Primitive Types and Variables

In This Chapter

In this chapter we will get familiar with primitive types and variables in C# – what they are and how to work with them. First we will consider the data types – integer types, real types with floating-point, Boolean, character, string and object type. We will continue with the variables, with their characteristics, how to declare them, how they are assigned a value and what a variable initialization is. We will get familiar with the two major sets of data types in C# – value types and reference types. Finally we will examine different types of literals and their usage.

What Is a Variable?

A typical program uses various values that change during its execution. For example, we create a program that performs some calculations on the values entered by the user. The values entered by one user will obviously be different from those entered in by another user. This means that when creating the program, the programmer does not know what values will be introduced as input, and that makes it necessary to process all possible values a user may enter.
When a user enters a new value that will be used in the process of calculation, we can preserve it (temporarily) in the random access memory of our computer. The values in this part of memory change (vary) throughout execution and this has led to their name – variables.

Post a Comment

1 Comments