Dark Knight Dark Knight - 28 days ago 4
C# Question

How can i check conflict in date time

How could i know if there's a conflict , example i have here
User Start time 7:00 AM End time 12:00 PM. Now if i add new Entry it should always CHECK the time. It shouldn't be the same with the first one. Meaning to say his time should be 12:00 PM Onwards. If his time is between 7-12. Example 11:00 AM this is CONFLICT since the first one has already workd in that time.

To be more clear
First entry .7:00 Am-12:00pm
Second entry 12:00pm-3pm
Third entry 3:00pm-7:00pm
And so on.
Thank you to those who will help.


Just do some checks on the three dates you are using. You should make an object for this but here is a simple code section of what it should look like.

        var start = DateTime.Now;
        var end = start.AddHours(3);
        var newStart1 = start.AddHours(2);
        if(newStart1> start && end<= newStart1)
            //valid time
            throw new Exception("Invalid start time.");