How to check if one DateTime is greater than the other in C#

前端 未结 10 630
遇见更好的自我
遇见更好的自我 2021-02-03 16:28

I have two DateTime objects: StartDate and EndDate. I want to make sure StartDate is before EndDate. How is this

10条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-03 17:17

    if (StartDate>=EndDate)
    {
        throw new InvalidOperationException("Ack!  StartDate is not before EndDate!");
    }
    

提交回复
热议问题