how to check if time is between two timespans in csharp

Code Example - how to check if time is between two timespans in csharp

                
                        if (interval.StartTime < interval.EndTime)
{
    // Normal case, e.g. 8am-2pm
    return interval.StartTime <= candidateTime && candidateTime < interval.EndTime;
}
else
{
    // Reverse case, e.g. 10pm-2am
    return interval.StartTime <= candidateTime || candidateTime < interval.EndTime;
}