Grow your YouTube channel like a PRO with a free tool
Get Free YouTube Subscribers, Views and Likes

Bad Date Comparisons in C# - if (DateTime.Now.ToString() == '01/01/2022

Follow
Scott Hanselman

An overly detailed analysis of a bad DateTime comparison in C#

if (DateTime.Now.ToString() == "01/01/2022 00:00:00")
{
Console.WriteLine("Happy New Year!");
}
else
{
Console.WriteLine("It's still 2021…");
}

posted by Regv5