Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C#

Giá trị MaxValue của DateTime trong C#

DateTime.MaxValue là ngày giờ lớn nhất có thể biểu diễn: 31/12/9999 23:59:59.9999999.

Ví dụ minh họa

using System;

public class Demo
{
    public static void Main()
    {
        DateTime max = DateTime.MaxValue;
        Console.WriteLine(max);
    }
}

Kết quả đầu ra

12/31/9999 11:59:59 PM

Cặp đôi: DateTime.MinValue = 01/01/0001 00:00:00 (thường dùng làm "null date" thay vì nullable).

Lưu ý: DateTime.MaxValue.Kind = Unspecified. Cẩn thận khi chuyển đổi múi giờ (TimeZoneInfo).