Dotnet, Development, C Sharp Programming, Csharp, Microsoft.
public class DemoService { private readonly TimeProvider _timeProvider; public DemoService(TimeProvider timeProvider) { _timeProvider = timeProvider; } public string GetTimeOfDay() { var currentTime = _timeProvider.GetUtcNow(); var message = currentTime.Hour switch { >= 6 and <= 12 => "Morning", >