How do I get the time difference between two DateTime objects using C#?

前端 未结 9 2186
臣服心动
臣服心动 2020-11-27 11:38

How do I get the time difference between two DateTime objects using C#?

9条回答
  •  一生所求
    2020-11-27 11:39

    You can use in following manner to achieve difference between two Datetime Object. Suppose there are DateTime objects dt1 and dt2 then the code.

    TimeSpan diff = dt2.Subtract(dt1);
    

提交回复
热议问题