DateTimeOffset.MaxValue 字段

定义

表示 DateTimeOffset 的最大可能值。Represents the greatest possible value of DateTimeOffset. 此字段为只读。This field is read-only.

public: static initonly DateTimeOffset MaxValue;
public static readonly DateTimeOffset MaxValue;
 staticval mutable MaxValue : DateTimeOffset
Public Shared ReadOnly MaxValue As DateTimeOffset 

字段值

异常

MaxValue 位于当前或指定区域性的默认日历的范围之外。MaxValue is outside the range of the current or specified culture's default calendar.

注解

此常量的值为 12/31/9999 11:59:59 PM + 00:00。The value of this constant is 12/31/9999 11:59:59 PM +00:00.

MaxValue 属性用于确定新 DateTimeOffset 对象的值或算术运算返回的 DateTimeOffset 值是否与此最大范围值相同或更早。The MaxValue property is used to determine whether the value of a new DateTimeOffset object or the DateTimeOffset value returned by an arithmetic operation is the same as or earlier than this maximum range value. 如果不是,则该方法引发 ArgumentOutOfRangeExceptionIf it is not, the method throws an ArgumentOutOfRangeException. 任何 DateTimeOffset 值都将转换为协调世界时(UTC),然后该方法才会将其与 MaxValue进行比较。Any DateTimeOffset value is converted to Coordinated Universal Time (UTC) before the method compares it with MaxValue. 这意味着,日期和时间接近最大范围但偏移量为负的 DateTimeOffset 值可能会引发异常。This means that a DateTimeOffset value whose date and time are close to the maximum range, but whose offset is negative, may throw an exception. 例如,值 12/31/9999 11:00 PM-02:00 超出范围,这是因为它在转换为 UTC 时比 MaxValue 晚一小时。For example, the value 12/31/9999 11:00 PM -02:00 is out of range because it is one hour later than MaxValue when it is converted to UTC.

某些日历(如 UmAlQuraCalendar)支持早于 MaxValue之前的日期范围。Some calendars, such as the UmAlQuraCalendar, support an upper date range that is earlier than MaxValue. 在这些情况下,尝试访问变量赋值或格式设置和分析操作中的 MaxValue 可能会引发 ArgumentOutOfRangeExceptionIn these cases, trying to access MaxValue in variable assignments or formatting and parsing operations can throw an ArgumentOutOfRangeException. 您可以从 Calendar.MaxSupportedDateTime 属性中检索指定区域性的最新有效日期值,而不是检索 DateTime.MaxValue的值。Instead of retrieving the value of DateTime.MaxValue, you can retrieve the value of the specified culture's latest valid date value from the Calendar.MaxSupportedDateTime property.

适用于