-
Couldn't load subscription status.
- Fork 6.1k
Closed
Description
Code example:
'private int year = 2023;
private static int ToDecadeBeginning(this int year) => year / 10 * 10;'
According to order of precedence of operators and operator associativity in this documentation,
I think this expression would evaluate to 2023 / (10 * 10) = 20.
Instead it evaluates to (2023 / 10) * 10 = 2020.
Associativity of this precedence level:
| x * y, x / y, x % y | Multiplicative |
|---|
Can I get an explanation of why, or may it be a bug in VS Studio (2022 and Code)?
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
- ID: 7eeac581-6235-2192-d909-e7fe3d21197f
- Version Independent ID: 9d8e2a57-1c18-8cba-9bd4-eef546fe2dcb
- Content: C# operators and expressions - List all C# operators and expression
- Content Source: docs/csharp/language-reference/operators/index.md
- Product: dotnet-csharp
- Technology: csharp-language-reference
- GitHub Login: @BillWagner
- Microsoft Alias: wiwagnx * y, x / y, x % y Multiplicative

