I’m developping an app in c#, and I was targeting net framework 4.0. On the proprieties window of my solution, I changed the target framework to NET Framework 2.0, but the app suddenly stopped working. It shows me the following error :
No overload for method ToString() takes 1 argument
The code that is causing the error :
DateTime endTime;
string endDate = get_end_date_fromDB();
if (DateTime.TryParseExact(endDate, "dddd, MMMM dd, yyyy", null, DateTimeStyles.None, out endTime))
{
TimeSpan ts = endTime.Subtract(DateTime.Now);
label1.Text = ts.ToString("d' Jours 'h' Heures 'm' Minutes'"); // <<<< THIS LINE IS CAUSING THE ERROR
}
Is there a workaround to make the code above work on C# 2.0? I need to show the date in a specific format.
Older implementation does not have
ToStringoverride with format parameter.You can find .NET version specific documentation on MSDN by choosing version of interest in “other versions” combobox.