简体   繁体   English

如何在时间范围内增加时间并向label2显示增加的时间? C#

[英]how can i add time within time and show to label2 the added time? c#

TimeAdded?

is there a way add time? 有没有办法增加时间? in the image 在图像中

if i click the AddedTimeButton the label1 or the running time will add another hour and show it to label2 如果我单击AddedTimeButton,label1或运行时间将再增加一个小时,并将其显示给label2

In the image label1 is 2:15:06 and if i click the button lets say the button can add 1 hour in the time and after i click it it will show in the label2 the added time 3:15:06. 在图像中label1是2:15:06,如果我单击按钮,可以说按钮可以增加1个小时的时间,单击它后,它将在label2中显示增加的时间3:15:06。

is there a logic code for it or is it possible? 是否有逻辑代码或可行?

Here's a high-level idea. 这是一个高层次的想法。 Please change it to suit your implementation. 请更改它以适合您的实现。

Label label1 = new Label();
Label label2 = new Label();

DateTime time = DateTime.Today;
label1.Text = time.ToString();

void OnButtonClicked()
{
     label2.Text = time.AddHours(1);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM