You can also subtract two datetime objects to get a timespan:
DateTime startDate;
DateTime endDate;
if(DateTime.TryParse(txtStartTime.Text, out startDate) && DateTime.TryParse(txtEndTime.Text, out endDate)){
TimeSpan duration = endDate - startDate;
int hours = duration.Hours;
}