Nullable DateTime in C#
问题 I have two questions related to DateTime assingments DateTime? y = 1 == 1 ? null: DateTime.MaxValue; DateTime? y = null; // assignment works as expected Why the first assignment issues error of type conversion between null and DateTime? Which is the preferred way for null assignments of DateTime? in c#. DateTime? x = default(DateTime?); //prints null on console DateTime? x = null; // prints null on console DateTime? x = DateTime.MinValue; //print 01/01/0001 回答1: The second statement DateTime?