Friday, 15 June 2012

c# - How can I format a nullable DateTime with ToString()? -


How can I change the nullable DateTime dt2 to an empty string?

  DateTime = DateTime.Now; Console.lightline (dt.tostring ("yyyy-MM-dd hh: mm: ss")); // Does the date work? DT2 = DateTime.Now; Console.light line (dt 2.toString ("yyyy-MM-dd hh: mm: ss")); // returns the following error:  

There is no overload for the method.

  console. WrightLine (dt2! = Null? Dt2.Value.ToString ("yyyy-MM-dd hh: mm: ss"): "n / a"); Edit: As mentioned in other comments, check that there is a non-empty value there. 


No comments:

Post a Comment