For the time in C # meets TimeSpan and you should work with it.
Read the value of:
Objects such as TimeSpan and DateTime (as well as their counterparts) have two methods ( Parse and ParseExact ), which are responsible for the “reading” of time from the String . Parse will be useful when time is running in a standard format (like hh: mm: ss). ParseExact in this regard is more flexible and allows you to customize the "Parsa" format of time.
Use ParseExact :
var time = TimeSpan.ParseExact("10д 5ч", "d'д 'h'ч'", null);
Here we split the input data, separating the plain text from the values of time itself. The values themselves are replaced with the format we need. Also, the method requires culture, here you can think yourself whether you need it or not ...
Get the necessary data:
get the time in hours (10 * 24 + 5) and get the number 245
When using the desired data type, we can easily operate this data as we go. In this case, all you need to do is find out the value of the TotalHours property:
var totalHours = time.TotalHours;
Reverse conversion:
The number (int) must be converted to days and hours
For this, there are methods such as FromHours() . They accept double value and give TimeSpan :
var result = TimeSpan.FromHours(totalHours);
Well, how to deduce, see it for yourself. Commonly used .ToString(); which can also accept a customizable format , so just play around with it and I think you will understand.
So good luck learning C #!