O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parentheses and Precedence

If the precedence and associativity rules do not correspond with your calculations, you can apply the parentheses operator ( <Numerical_expression> ) to control the order in which each operator is applied in an arithmetic expression.

Syntax Box 7.3 The Parentheses Operator

						Parenthesized_expression ::=

                 ( <Numerical_expression> )

Parentheses in C# are used in the same way as in algebra and arithmetic to accomplish this task. Because of their higher precedence level (as shown in Table 7.1), they have first priority over any precedence rules set for most other operators. The next example illustrates.

We want to construct a statement that finds the average time two people spend exercising every day. Our first attempt, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required