Having two different string times such as
var beginning = "22:30:00";
var end= "23:00:00";
var horaActual = DateTime.Now;
How can I know when current time is between them?
I am triying with this way:
horaRango = DateTime.Now.Date.Add(TimeSpan.Parse(beginning));
horaAgendada = DateTime.Now.Date.Add(TimeSpan.Parse(end));
if (horaActual >= horaRango && horaActual <= horaAgendamiento)
{
//is between
}
But is not working pretty well
I am getting this error with my code:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best overloaded method match for 'System.TimeSpan.Parse(string)' has some invalid arguments at CallSite.Target(Closure , CallSite , Type , Object )
Any idea?