如何在Windows Phone 7中从DateTime中减去一秒?

本文关键字:一秒 Windows Phone DateTime 中从 | 更新日期: 2023-09-27 18:04:35

我试图从时间选择器中的时间值减去一秒。我找到了将秒添加到选择器值的代码,但我不知道如何减去。

我该怎么做呢?

private static void CreateAlarm(DateTime time, string title)
{
    var alarm = new Alarm(title)
    {
        Content = "You have a meeting with your team now.",
        BeginTime = time.AddSeconds(10),
    };
}
private void SetAlarm_Click(object sender, RoutedEventArgs e)
{
    CreateAlarm(Convert.ToDateTime(timePicker1.ValueString), textBox1.Text);
}

如何在Windows Phone 7中从DateTime中减去一秒?

加一个减号:

EndTime = time.AddSeconds(-10)