Which variable should I use if I want to save time values?

I want to create an application that adds 1 minute and 25 seconds to a TimeLeft variable.

The problem is that I have no idea what type of variable it should be, or even how to add 1 minute 25 seconds to the remaining time.

Any guidance would be greatly appreciated. I am very familiar with C #, but since I have never done anything like this, I am in the dark.

+3
source share
3 answers

I would suggest you use a variable DateTime. This will allow you to manipulate time. If you want to add 1m 25s to varible, you can simply use:

DateTime newTime = DateTime.Now.AddSeconds(85);

85 (, , TimeLeft, TimeLeft DateTime)

+3
+3

Use the DateTime type. Assuming your TimeLeft variable is an integer, you probably need to convert it to a DateTime type first and then do the addition. More info here

0
source

Source: https://habr.com/ru/post/1730810/


All Articles