
62
|
Chapter 4: Variables and Data Types
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Address
Every variable has an associated memory address, the location where the vari-
able’s value is stored. Variables are not guaranteed to maintain a permanent
memory address in .NET, so the address of a variable should not be recorded
or used.
Data Type
The data type of a variable determines the possible values that the variable
can assume.
Value
The value of a variable is the data content it contains at its memory address.
This is also sometimes referred to as the r-value of the variable, since it is
what appears on the right side of a variable assignment statement. For
instance, in the code:
Dim targetValue As Integer = 5
the statement can be read as “store the value of 5 in memory at the address of
targetValue.” Because it appears on the left side of an assignment operator,
the variable (or its memory location) is sometimes called an l-value.
Scope
The scope of a variable determines where in a program that variable is visible
to the code. Variable scope is discussed in more detail later in this chapter.
Lifetime
A variable’s lifetime determines when and for how long a particular variable
exists. It may or may not be visible (that is, be in scope) for that entire period.
Variable lifetime is described in more detail later in this chapter.
Variable ...