I have two text boxes In time and out time , i need to validate out time should not less than 2 hours of in time
I need to validate the In time and out time
Collapse
X
-
Tags: None
-
Code:try { DateTime intime; DateTime.TryParse(textBox1.Text, out intime); DateTime outtime; DateTime.TryParse(textBox2.Text, out outtime); TimeSpan t = (outtime - intime).Duration(); MessageBox.Show("The difference between " + intime.ToShortTimeString() + " and " + outtime.ToShortTimeString() + " is: " + t.TotalSeconds + " seconds"); } catch(Exception ex) { MessageBox.Show("Invalid time " + ex.Message); }
Comment