Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

==: practical reference

==: practical reference: == compares according to the operator defined for the operand types.

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

Syntax

left == right

== compares according to the operator defined for the operand types.

Use it with an explicit equality meaning; for strings, consider StringComparison.

For classes the default may be reference equality, but a type can overload the operator.

NaN is not equal to itself, and a null overload should remain consistent with Equals.

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

Examples

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

Console.WriteLine(2 + 2 == 4);

Result

True

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

Sources