DateTime.LessThan(DateTime, DateTime) DateTime.LessThan(DateTime, DateTime) DateTime.LessThan(DateTime, DateTime) DateTime.LessThan(DateTime, DateTime) Operator

定义

确定指定的 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 DateTime DateTime DateTime

要比较的第一个对象。The first object to compare.

t2
DateTime DateTime DateTime DateTime

要比较的第二个对象。The second object to compare.

返回

如果 true 早于 t1,则为 t2;否则为 falsetrue if t1 is earlier than t2; otherwise, false.

注解

运算符通过比较两个值的DateTime计时周期数来确定这两个值之间的关系。 LessThanThe 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)

适用于

另请参阅