shreyas adikumar

shreyas adikumar

  • NA
  • 53
  • 5.2k

compare time with current time

Sep 28 2018 2:54 AM
hi, I am trying with comparing time with current time using if statement output is going wrong can I know what is the problem.
 
string minute = "15";
string minute2 = "20";
string minute3 = "27";
string minute4 = "02";
TimeSpan first = TimeSpan.Parse(minute);
TimeSpan second = TimeSpan.Parse(minute2);
TimeSpan Third = TimeSpan.Parse(minute3);
TimeSpan fourth = TimeSpan.Parse(minute4);
TimeSpan now = DateTime.Now.TimeOfDay;
if (now == first|| now == second || now == Third || now == fourth)
{
//matched
}
else
{
}
}
 
can I please know where I went wrong.

Answers (6)