c# 计算时间间隔
最近在做WP7项目的优化,总要计算间隔时间,附一段代码备忘。
private TimeSpan m_BeginTimeSpan;
private TimeSpan m_StopTimeSpan;
public NewsCenterView()
{
m_BeginTimeSpan = new TimeSpan(System.DateTime.Now.Ticks);
****
}
void NewsCenterView_Loaded(object sender, RoutedEventArgs e)
{
***
m_StopTimeSpan = new TimeSpan(System.DateTime.Now.Ticks);
MessageBox.Show(m_StopTimeSpan.Subtract(m_BeginTimeSpan).TotalMilliseconds.ToString());
}