Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

%=: practical reference

%=: practical reference: %= computes a remainder and assigns it to the left operand.

Version: C# operator reference; verified against C# 14

Syntax

left %= right

%= computes a remainder and assigns it to the left operand.

Use it to wrap a counter, normalizing negative values separately.

It preserves the sign of the left operand and is not atomic.

Zero has type-specific exception or NaN behavior, and the result converts to the left type.

The complete program actually uses %=; its exact expected stdout is 2.

Examples

using System;
using System.Linq;
using System.Threading.Tasks;

var value = 17; value %= 5; Console.WriteLine(value);

Result

2

The complete program actually uses `%=`; its exact expected stdout is `2`.

Sources