<= : Less Than or Equal Operator
On this page
Summary
Compare if the left value is less than or equal to the right value.
Syntax
Precedence
Priority level in expression evaluation (1 = highest, 10 = lowest): 6
Evaluated after: ^, *, /, %, +, -
Evaluated before: ==, !=, ??, &&, ||
Operands
| Position | Type | Description |
|---|---|---|
| Left | Comparable | First value to compare |
| Right | Comparable | Second value to compare |
Returns
Type: Boolean
true if left operand is less than or equal to right operand, false otherwise.
Examples
Low Stock Alert
Data:
doc.Params["model"] = new {
stock = 8
};
Output:
<div class="alert-warning">
<strong>Low Stock Warning</strong>
<p>Only 8 units left - reorder soon!</p>
</div>
Score Validation
Capacity Check
Data:
doc.Params["model"] = new {
attendees = 98,
capacity = 100
};
Output:
<span class="available">2 spots available</span>
Date Deadline Check
Price Range Filter
Data:
doc.Params["model"] = new {
maxBudget = 50,
products = new[] {
new { name = "Basic Widget", price = 29.99m },
new { name = "Premium Widget", price = 79.99m },
new { name = "Standard Widget", price = 49.99m }
}
};
Output:
<div class="product-affordable">
<h3>Basic Widget</h3>
<p>$29.99</p>
<span class="badge">Within Budget</span>
</div>
<div class="product-affordable">
<h3>Standard Widget</h3>
<p>$49.99</p>
<span class="badge">Within Budget</span>
</div>
Notes
- Works with numbers, dates, and comparable types
- Includes equality (
=) unlike<operator - String comparison is case-sensitive and uses lexicographic ordering
- Date comparison compares chronological order
- Cannot compare incompatible types
- Commonly used with `` for conditional rendering
- Can be combined with logical operators (
&&,||)
See Also
- Less Than Operator
- Greater Than Operator
- Greater Than or Equal Operator
- Equality Operator
- #if Helper