new DateTime() vs default(DateTime)

RJP picture RJP · Dec 19, 2012 · Viewed 216.3k times · Source

Is there a reason to choose one of these over the other?

DateTime myDate = new DateTime();

or

DateTime myDate = default(DateTime);

Both of them are equal 1/1/0001 12:00:00 AM.

Answer

Servy picture Servy · Dec 19, 2012

No, they are identical.

default(), for any value type (DateTime is a value type) will always call the parameterless constructor.