Changes

Jump to: navigation, search

C Sharp Operators and Expressions

837 bytes added, 19:20, 14 January 2008
C# Arithmetic Operators
The following table lists the primary C# arithmetic operators:
 
<table border="1" cellspacing="0">
<tr style="background:#efefef;">
<th>Operator</th><th>Description</th>
<tr>
<td>-(unary)<td>Negates the value of</td>
<tr>
<td>*<td>Multiplication</td>
<tr>
<td>/<td>Division</td>
<tr>
<td>+<td>Addition</td>
<tr>
<td>-<td>Subtraction</td>
<tr>
<td>%<td>Modulo</td>
</table>
 
Note that multiple operators may be used in a single expression. For example:
 
<pre>
x = y * 10 + z - 5 / 4;
</pre>
 
Whilst the above code is perfectly valid it is important to be aware that C# does not evaluate the expression from left to right ot right to left, but rather in an order specified by the precedence of the various operators. ''Operator precedence'' is an important topic to understand since it impacts the result of a calculation and will be covered in detail i the next section.
 
== C# Operator Precedence ==
== Compound Assignment Operators ==

Navigation menu