System.DateTimeOffset.op_Inequality Method

Determines whether two specified DateTimeOffset objects refer to different points in time.

Syntax

public static bool operator!= (DateTimeOffset left, DateTimeOffset right)

Parameters

left
The first object to compare.
right
The second object to compare.

Returns

true if left and right do not have the same DateTimeOffset.UtcDateTime value; otherwise, false.

Remarks

The DateTimeOffset.op_Inequality(DateTimeOffset, DateTimeOffset) method defines the operation of the inequality operator for DateTimeOffset objects. It always returns the opposite result from DateTimeOffset.op_Equality(DateTimeOffset, DateTimeOffset). The DateTimeOffset.op_Inequality(DateTimeOffset, DateTimeOffset) method enables code such as the following:

code reference: System.DateTimeOffset.Operators#8

Before evaluating the left and right operands for equality, the operator converts both values to Coordinated Universal Time (UTC). The operation is equivalent to the following:

code reference: System.DateTimeOffset.Syntax#4

In other words, the DateTimeOffset.op_Inequality(DateTimeOffset, DateTimeOffset) method determines whether the two DateTimeOffset objects represent different points in time. It directly compares neither dates and times nor offsets.

Languages that do not support custom operators can call the DateTimeOffset.Compare(DateTimeOffset, DateTimeOffset) method instead. In addition, some languages can also call the DateTimeOffset.op_Inequality(DateTimeOffset, DateTimeOffset) method directly, as the following example shows.

code reference: System.DateTimeOffset.Operators#9

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0