CKTIS / C#
--: practical reference
--: practical reference: -- decreases a variable by one; prefix yields the new value and postfix the previous value.
Version: C# language; verified against C# 14 reference
Syntax
--operand / operand---- decreases a variable by one; prefix yields the new value and postfix the previous value.
Use it on a local counter where read order is obvious.
Prefix/postfix differences and side effects make compound expressions hard to reason about.
An integral MinValue can wrap or throw in a checked context.
The complete program actually uses --; its exact expected stdout is 3\n2.
Examples
using System;
using System.Linq;
using System.Threading.Tasks;
var value = 3; Console.WriteLine(value--); Console.WriteLine(value);
Result
3 2
The complete program actually uses `--`; its exact expected stdout is `3\n2`.