Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

^: practical reference

^: practical reference: ^ performs bitwise XOR or Boolean exclusive difference.

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

Syntax

left ^ right

^ performs bitwise XOR or Boolean exclusive difference.

Use it to toggle bits or test that exactly one of two Boolean values is true.

It is not exponentiation, and both Boolean operands always execute.

Numeric promotion and signed width affect the representation of the result.

The complete program actually uses ^; its exact expected stdout is 6.

Examples

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

Console.WriteLine(5 ^ 3);

Result

6

The complete program actually uses `^`; its exact expected stdout is `6`.

Sources