how to compare two dates in datetimepicker

前端 未结 2 1037
谎友^
谎友^ 2021-01-24 04:59

I am doing Windows project, in which I have two DateTimePicker controls, one for StartDate and other for EndDate.

In runtime, when user selects the StartDate and EndDate

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-24 05:24

    I would recommend using DateTime.TryParse (doc here) instead of just converting. That will allow you to provide valid formatting, handle failures (convert will throw if it fails).

    The part about using the Date property seems fine, and comparison operators will work as expected.

提交回复
热议问题