Is it possible to conveniently store values ​​like TimeSpan in app.config? To not set them in seconds:

<appSettings> <add key="Task1Name:PollingInterval" value="300" /> </appSettings> 

Now I keep the number of seconds and do not like the extra work on the conversion:

 int.TryParse(ConfigurationManager.AppSettings["Task1Name:PollingInterval"], out var pollingInterval); if (pollingInterval == 0) pollingInterval = 1000; return new IStartStopSevice[] { new MyTask1(TimeSpan.FromSeconds(pollingInterval)), }; 

Perhaps in the new versions of the language there is some additional syntactic sugar to reduce the number of lines?

About option

 new MyTask1(TimeSpan.FromSeconds(pollingInterval == 0 ? 1000 : pollingInterval)), 

I know.

0