Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

<<=: practical reference

<<=: practical reference: <<= shifts the left operand and assigns the converted result back to its type.

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

Syntax

left <<= right

<<= shifts the left operand and assigns the converted result back to its type.

Use it to update a mask or encode bit fields.

It is not atomic and can silently discard the highest bits.

The shift count is masked, while smaller types are promoted before assignment.

The complete program actually uses <<=; its exact expected stdout is 12.

Examples

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

var value = 3; value <<= 2; Console.WriteLine(value);

Result

12

The complete program actually uses `<<=`; its exact expected stdout is `12`.

Sources