-1

在c# 4.0中,如何在文本框中检查日期,日期是否大于或等于

DateTime StartDate =  Convert.ToDateTime(TxtStrtDate.Text);
DateTime ExpirationDate = Convert.ToDateTime(TxtExpDte.Text);

谢谢

4

2 回答 2

8

怎么样

bool b = ExpirationDate >= StartDate;

阅读此DateTime.GreaterThanOrEqual 运算符

或者

int i = DateTime.Compare(ExpirationDate, StartDate);

//if ExpirationDate is less than StartDate then result is Less than zero

//if ExpirationDate equals StartDate then result is Zero

//if ExpirationDate is greater than StartDate then result is Greater than zero
于 2012-06-09T12:58:07.587 回答
2

DateTime.Compare()是我能想到的最简单的方法。

于 2012-06-09T13:07:19.353 回答