Farzad Jafarizadeh Farzad Jafarizadeh - 8 months ago 67
C# Question

'DateTime' does not contain a definition for 'ToShortDateString' in VS2015

Had the following issue when created universal app in VS 2015 and tried to use .ToShortDateString() method for DateTime in the Shared Project.
Visual Studio 2015 intellisense shows this as an error, but the application runs fine. Just wondering, is this a bug in VS or am I missing something?

enter image description here

enter image description here


UWP apps use the new CoreCLR for compilation. The CoreCLR does not support DateTime.ToShortDateString at this time, and it doesn't seem to be getting much traction anyways. Those helper methods are bad at localization.

You can simply replace the call with dateToDisplay.ToString("d").


Looks like it got some traction! This method (along with several others) was added back into the CoreCLR. This move was done to improve parity with the APIs in Xamarin and the .Net Framework. You can read more about this decision here.