Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

/=: practical reference

/=: practical reference: /= divides and assigns the result under compound-assignment rules.

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

Syntax

left /= right

/= divides and assigns the result under compound-assignment rules.

Use it to update a variable only when truncation of a fractional part is intended.

For int, the result remains int even when the mathematical quotient is fractional.

Division by zero and MinValue/-1 overflow have type-specific behavior.

The complete program actually uses /=; its exact expected stdout is 3.

Examples

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

var value = 7; value /= 2; Console.WriteLine(value);

Result

3

The complete program actually uses `/=`; its exact expected stdout is `3`.

Sources