+ : Addition Operator
On this page
Summary
Adds two numeric values together.
Syntax
Operands
| Position | Type | Description |
|---|---|---|
| Left | Number | First value to add |
| Right | Number | Second value to add |
Returns
Type: Number (same type as operands, or promoted type)
The sum of the two operands.
Examples
Basic Addition
With Variables
Data:
doc.Params["model"] = new {
price = 99.99m,
tax = 8.00m
};
Output:
<p>Subtotal: $99.99</p>
<p>Tax: $8.00</p>
<p>Total: $107.99</p>
Multiple Additions
With Formatting
In #each Loop
Precedence
Priority level in expression evaluation: 5 (after *, /, %)
Notes
- Works with
int,long,double,decimaltypes - Mixed types are automatically converted (e.g.,
int + double=double) - Left-to-right associativity:
a + b + c=(a + b) + c - Use parentheses to control order:
(a + b) * c