Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

*=: practical reference

*=: practical reference: *= multiplies and assigns under compound-assignment conversion rules.

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

Syntax

left *= right

*= multiplies and assigns under compound-assignment conversion rules.

Use it to scale a variable when the final conversion is intentional.

Small types are promoted for calculation and then converted back to the left-side type.

Overflow follows checked context, and the operation is not atomic across threads.

The complete program actually uses *=; its exact expected stdout is 42.

Examples

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

var value = 6; value *= 7; Console.WriteLine(value);

Result

42

The complete program actually uses `*=`; its exact expected stdout is `42`.

Sources