<1>
Using system;using system.collections.generic;using system.linq;using system.text;namespace Test{class Program { static void Main (string[] args) {DateTime T1 = datetime.parse ("2007-01-01"); DateTime t2 = datetime.parse ("2006-01-01"); system.timespan t3 = t1-t2; Subtract two times. The default is to get the number of days between two times: 365.00:00:00 double getDay = t3. Totaldays; Convert this number of days to days, the return value is double type (actually do not have to convert, because T3 default is the number of days) get: Double getHours = t3. TotalHours; Convert this number of days to hours, and the return value is double of type getminute = T3. Totalminutes; Convert this number of days to the component clock, and the return value is double of type getseconds = T3. TotalSeconds; Converts this number of days to seconds, and the return value is double of type getmillisecond = T3. TotalMilliseconds; Converts this number of days to milliseconds, and the return value is a double of type Console.WriteLine (T3); Output: 365.00:00:00 Console.WriteLine (GetDay); Output: 365 Console.WriteLine (getHours); Output: 8760 Console.WriteLine (Getminute); Output: 525600 Console.WriteLine (getseconds); Output: 31536000 Console.WriteLine (Getmillisecond); Output: 31536000000 console.readkey (); }
Subtract two times