Previous Page
Next Page

Chapter 2 Quick Reference

To

Do this

Declare a variable

Write the name of the data type, followed by the name of the variable, followed by a semicolon. For example:

int outcome;

Change the value of a variable

Write the name of the variable on the left, followed by the assignment operator, followed by the expression calculating the new value, followed by a semicolon. For example:

outcome = 42;

Convert a string to an int

Call the System.Int32.Parse method. For example:

System.Int32.Parse("42");

Override precedence

Use parentheses in the expression to force operands to bind to specific operators. For example:

(3 + 4) * 5

Increment or decrement a variable

Use the ++ or <;$MI><;$MI> operator. For example:

count++;

Previous Page
Next Page