Alvin Ashcraft’s Morning Dew

Daily .NET Development Links with an ALT.NET Slant

Entries Comments



Nullable DateTime in .NET 2.0

24 May, 2007 (15:18) | Uncategorized | By: Alvin Ashcraft

Thanks to generics in 2.0, now any value type can be NULL.

    public class DateTimeNullTest    {        private Nullable<DateTime> oDate = new Nullable<DateTime>(DateTime.Now);

        public DateTimeNullTest()        {            // Yay - It doesn't blow up!            if (oDate != null)                oDate = null;        }    }

 


AddThis Social Bookmark Button var addthis_pub = ‘alashcraft’;

Technorati tags: , , , ,

Write a comment