It is pretty simple:
TimeSpan diff = secondDate - firstDate; double hours = diff.TotalHours;
Note that if these DateTime values were taken locally, the result may not be the number of elapsed hours. For example, you might have one DateTime midnight and one of 2 in the morning, but only one hour has passed - because the clock went ahead at 1 am. This may or may not be a problem for you. This is not a problem if you are dealing with UTC DateTime values.
Jon skeet
source share