DateTimeOffset.Equality(DateTimeOffset, DateTimeOffset) Operador

Definição

Determina se dois objetos DateTimeOffset especificados representam o mesmo ponto no tempo.Determines whether two specified DateTimeOffset objects represent the same point in time.

public:
 static bool operator ==(DateTimeOffset left, DateTimeOffset right);
public static bool operator == (DateTimeOffset left, DateTimeOffset right);
static member ( = ) : DateTimeOffset * DateTimeOffset -> bool
Public Shared Operator == (left As DateTimeOffset, right As DateTimeOffset) As Boolean

Parâmetros

left
DateTimeOffset

O primeiro objeto a ser comparado.The first object to compare.

right
DateTimeOffset

O segundo objeto a ser comparado.The second object to compare.

Retornos

Boolean

true se ambos os objetos DateTimeOffset tiverem o mesmo valor UtcDateTime; caso contrário, false.true if both DateTimeOffset objects have the same UtcDateTime value; otherwise, false.

Comentários

O Equality método define a operação do operador de igualdade para DateTimeOffset objetos.The Equality method defines the operation of the equality operator for DateTimeOffset objects. Ele permite que o código seja o seguinte:It enables code such as the following:

DateTimeOffset date1 = new DateTimeOffset(2007, 6, 3, 14, 45, 0,
             new TimeSpan(-7, 0, 0));
DateTimeOffset date2 = new DateTimeOffset(2007, 6, 3, 15, 45, 0,
             new TimeSpan(-6, 0, 0));
DateTimeOffset date3 = new DateTimeOffset(date1.DateTime,
             new TimeSpan(-6, 0, 0));
Console.WriteLine(date1 == date2);        // Displays True
Console.WriteLine(date1 == date3);        // Displays False
Dim date1 As New DateTimeOffset(#6/3/2007 2:45PM#, _
             New TimeSpan(-7, 0, 0))
Dim date2 As New DateTimeOffset(#6/3/2007 3:45PM#, _
             New TimeSpan(-6, 0, 0))
Dim date3 As New DateTimeOffset(date1.DateTime, _
             New TimeSpan(-6, 0, 0))
Console.WriteLine(date1 = date2)        ' Displays True
Console.WriteLine(date1 = date3)        ' Displays False

Antes de avaliar left os right operandos e para igualdade, o operador converte ambos os valores em UTC (tempo Universal Coordenado).Before evaluating the left and right operands for equality, the operator converts both values to Coordinated Universal Time (UTC). A operação é equivalente ao seguinte:The operation is equivalent to the following:

return first.UtcDateTime == second.UtcDateTime;
Return first.UtcDateTime = second.UtcDateTime

Em outras palavras, o Equality método determina se os dois DateTimeOffset objetos representam um único ponto no tempo.In other words, the Equality method determines whether the two DateTimeOffset objects represent a single point in time. Ele não compara diretamente datas e horas nem deslocamentos.It directly compares neither dates and times nor offsets. Para determinar se dois objetos DateTimeOffset representam a mesma hora e têm o mesmo valor de deslocamento, use o método EqualsExact.To determine whether two DateTimeOffset objects represent the same time and have the same offset value, use the EqualsExact method.

O método equivalente para esse operador é DateTimeOffset.Equals(DateTimeOffset, DateTimeOffset)The equivalent method for this operator is DateTimeOffset.Equals(DateTimeOffset, DateTimeOffset)

Aplica-se a

Confira também