new DateTime() vs default(DateTime)
No, they are identical.
default()
, for any value type (DateTime
is a value type) will always call the parameterless constructor.
If you want to use default value for a DateTime parameter in a method, you can only use default(DateTime).
The following line will not compile:
private void MyMethod(DateTime syncedTime = DateTime.MinValue)
This line will compile:
private void MyMethod(DateTime syncedTime = default(DateTime))
The answer is no. Keep in mind that in both cases, mdDate.Kind = DateTimeKind.Unspecified
.
Therefore it may be better to do the following:
DateTime myDate = new DateTime(1, 1, 1, 0, 0, 0, DateTimeKind.Utc);
The myDate.Kind
property is readonly, so it cannot be changed after the constructor is called.