RJP RJP -4 years ago 177
C# Question

new DateTime() vs default(DateTime)

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

DateTime myDate = new DateTime();


DateTime myDate = default(DateTime);

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

Answer Source

No, they are identical.

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download