5.3. Statements

To make a program or a web site do something useful, you need to provide it with statements that it can execute. Statements cover a wide range of actions, like: show this button, send this e-mail, execute this and that code when a user clicks that button, and so on. However, simply executing these actions is not enough. You often need to execute some code only when a certain condition is true. For example, if a visitor to an e-commerce web site is buying more than $100 of merchandise at one time, they might get a discount of 10 percent. Otherwise, they pay the full price. Conditions or decisions are therefore very important statements in a programming language. Another important set of statements is the loops. Loops allow you to repeat a certain piece of code a number of times. For example, you can have a loop that goes from 1 to 10, performing some action on each iteration. Or you can loop through the products in a shopping cart, summing up the total price for example.

The final important set of statements is the operators. Operators allow you to do something with your values; or, to be more exact, they allow you to operate on them. For example, you use operators to subtract values, concatenate (combine) them, or compare them to each other.

The following three sections dig deeper into operators, decision making, and loops.

5.3.1. Operators

The most important operators can be grouped logically into five different types. Of these five groups, the assignment operators ...

Get Beginning ASP.NET 3.5: In C# and VB now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.