DateTime.LessThan(DateTime, DateTime) 運算子

定義

判斷某個指定的 DateTime 是否早於另一個指定的 DateTimeDetermines whether one specified DateTime is earlier than another specified DateTime.

public:
 static bool operator <(DateTime t1, DateTime t2);
public static bool operator < (DateTime t1, DateTime t2);
static member ( < ) : DateTime * DateTime -> bool
Public Shared Operator < (t1 As DateTime, t2 As DateTime) As Boolean

參數

t1
DateTime

要比較的第一個物件。The first object to compare.

t2
DateTime

要比較的第二個物件。The second object to compare.

傳回

true 早於 t1 時為 t2,否則為 falsetrue if t1 is earlier than t2; otherwise, false.

備註

LessThan 運算子會藉由比較其刻度數來決定兩個 DateTime 值之間的關聯性。The LessThan operator determines the relationship between two DateTime values by comparing their number of ticks. 在比較 DateTime 物件之前,請確定物件代表相同時區中的時間。Before comparing DateTime objects, make sure that the objects represent times in the same time zone. 只要比較其 Kind 屬性的值,即可做到這一點。You can do this by comparing the values of their Kind property.

這個運算子的對等方法是 DateTime.Compare(DateTime, DateTime)The equivalent method for this operator is DateTime.Compare(DateTime, DateTime)

適用於

另請參閱