#967 – Assigning a Value to a Variable

You store a value in a variable, or assign the value, use the = operator.  The = operator is known as the simple assignment operator.

When using the simple assignment operator, the value of the right operand is computed and the result is stored in the variable that appears as the left operand.

myInteger = 5;       // 5 stored in myInteger
myInteger = 8 + 3;   // 11 stored in myInteger

The right operand is an expression containing one or more operands and operators that is evaluated to determine a resulting value.  Operands within the expression can be constants, variables, properties or the results of function calls.

            myInteger = (12 + (8 * TripleThisNumber(2))) / myDog.Age;

The left side of an assignment statement can specify a variable, a property, or an indexer access.

            myDog.Age = 12;
            myArray[2] = 42;
Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: