24 May 2007

Nullable DateTime in .NET 2.0

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


Technorati tags: , , , ,

No comments: