Hello all,

I am making one application in which I need to enter the start and stop time in textbox. I have used masked text box. I want to check that Stop time should be greater than Start time and also the time entered should be in valid time format other-wise error message should be displayed.

can anyone help please, Thankyou

Have you started? Are there any particular parts you are finding hard? Try posting what you have done so far, and what your problem is with how to procede

You can use DateTime.TryParse to convert each entered time into a DateTime. If it fails then you can alert the user:

static void Main(string[] args)
        string startTime = Console.ReadLine();
        string stopTime = Console.ReadLine();
        DateTime start;
        DateTime stop;
        if (!DateTime.TryParse(startTime, out start))
            Console.WriteLine("Invlaid Start Time");

        if(!DateTime.TryParse(stopTime, out stop))
            Console.WriteLine("Invalid Stop Time");



You pass the method the string you wish to convert and assign an out parameter of type DateTime where you want the result to be stored. The method will store the converted value in the out parameter if it is successful.
The method itself returns a boolean to indicate success or failure, hence you can palce it in an if statement. The above says "if TryParse fails, do something" (notice the '!' not symbol before DateTime.TryParse).

Hope this gets you moving in the right direction. Have a go and psot if you get stuck.