Team LiB
Previous Section Next Section

Predefined Types

C# is said to be a strongly typed programming language in that when a variable is declared, its type must also be declared. Among other things, declaring a variable's type tells the compiler how much memory to allocate for the variable.

The C# language and .NET Framework make use of the Common Type System (CTS), a specification that defines a set of types as well as the behavior of those types. The CTS defines a wide variety of types in two main families—value types and reference types. In this chapter, we'll focus on C#'s predefined value types, also known as simple types, along with the string type, which happens to be a reference type; we'll defer a discussion of reference types in general until Chapter 3.

The C# language supports a variety of simple types. The most commonly used types are as follows (all of these are C# keywords):

Each variable declared to be of a simple type represents a single integer, floating point, Boolean, byte, or character value.


Team LiB
Previous Section Next Section