SHARE
TWEET

Untitled

a guest Jul 17th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DateTime? y = 1 == 1 ? null: DateTime.MaxValue;
  2. DateTime? y = null; // assignment works as expected
  3.      
  4. DateTime? x = default(DateTime?); //prints null on console
  5.  
  6. DateTime? x = null;               // prints null on console
  7.  
  8. DateTime? x = DateTime.MinValue;  //print 01/01/0001
  9.      
  10. DateTime? y = 1 == 1 ?(DateTime?) null : DateTime.MaxValue;
  11.      
  12. DateTime? y = 1 == 1 ? null : (DateTime?)DateTime.MaxValue;
  13.      
  14. DateTime? y = 1 == 1 ? (DateTime?)null : DateTime.MaxValue;
  15.      
  16. DateTime? x = null;
  17.      
  18. //Which is the preferred way for null assignments of DateTime? in c#.
  19.  
  20. DateTime? x = default(DateTime?); //prints null on console
  21.  
  22. DateTime? x = null; // prints null on console
  23.  
  24. DateTime? x = DateTime.MinValue; //print 01/01/0001
  25.      
  26. int y = 1;
  27.   DateTime? dt3 = y == 1 ? (DateTime?)null : DateTime.MinValue;
  28.      
  29. DateTime? dt3 = null;
  30.  
  31.         if (y == 1)            
  32.              dt3 = null;            
  33.         else
  34.             dt3 = DateTime.MinValue;
  35.      
  36. DateTime? dt = (DateTime?)null;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top