'ToString()' takes 1 arguments when DateTime?(Nullable) type I uses [duplicate]
问题 This question already has answers here : No overload for method 'ToString" takes 1 arguments when casting date (3 answers) Closed 3 years ago . DateTime? NullableWhen I use DateTime? as Nullable type "ToString("dd MMMMyyyy " + "(HH:mm tt)")" error appears. 回答1: You must use something like this. I've added null check as suggested by Colin if(dateVariable.HasValue) string dateString = dateVariable.Value.ToString("dd MMMMyyyy " + "(HH:mm tt)"); Nullable<T> is a generc and it wraps object. You