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

When creating a universal application in VS 2015, the following problem arose: he tried to use the .ToShortDateString () method for DateTime in a common project. Visual Studio 2015 intellisense shows this as an error, but the application is working fine. Just wondering, is this a bug in VS or am I missing something?

enter image description here

enter image description here

+5
source share
2 answers

UWP applications use the new CoreCLR to compile. Currently, CoreCLR does not support DateTime.ToShortDateString , and in any case, it does not seem to get much traction . These helper methods are bad at localization.

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

Update

He seems to have some kind of craving! This method (along with several others) was added back to CoreCLR . This step was taken to improve parity with the API in Xamarin and the .NET Framework. You can learn more about this solution here .

+7
source

This is only an error, because code analysis is considered to be considered an error. You can change this to a warning or ignore it completely, but it is recommended that you improve the code.

0
source

All Articles