Chapter 3. Understanding Data Types

As you learned in Chapter 2, computer programs often input data in one form, process it, and then show the new data on the computer screen. This kind of invites the question: What is data? Simply stated, data is information. Computer data is information that is stored in a variable for use in a program. In a broad sense, there are two basic kinds of computer data: 1) numeric data and 2) textual data.

Numeric data is any kind of data that can have arithmetic operations performed on it. You can add, subtract, multiply, and divide numeric data. You can perform other operations on numeric data, like finding a square root, a sine, or a cosine of a numeric quantity, and so on. You will also hear numeric data types referred to as value types. The precise meaning of this term is discussed in Chapter 5. For now, however, you can think of them as those data types whose variables can have data stored directly into them.

Textual data are character representations of data. Your name is a piece of data that can be represented in a program in a textual fashion. Some students get confused when you ask them whether a zip code is numeric or textual information. Because zip codes are usually not manipulated in mathematical expressions (for example, you wouldn't need to multiply or divide a zip code), they are usually treated as textual information.

This chapter discusses the different data types C# provides to you. In this chapter, you will learn about the following: ...

Get Beginning C# 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.