Constant DateTime in C#

As some of the earlier responses note, a const DateTime is not natively supported in C# and can’t be used as an attribute parameter. Nevertheless, a readonly DateTime (which is recommended over const in Effective C#, 2nd edition [Item 2]) is a simple workaround for other situations as follows:

public class MyClass
{
    public static readonly DateTime DefaultDate = new DateTime(1900,1,1);
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)