かどうかを確認する関数を作成するのはなぜstartDate < endDate
ですか?
private void button1_Click(object sender, EventArgs e)
{
DateTime startDate = new DateTime(2012 , 05 , 25);
DateTime endDate = new DateTime(2012 , 05 , 31);
bool rtnval = IsValidDate(startDate, endDate);
}
public bool IsValidDate(DateTime startDate, DateTime endDate)
{
return startDate < endDate && endDate > startDate;
}
このコードは true を返します!!!
それを分割して、必要な値があることを確認します
public bool IsValidDate(DateTime startDate, DateTime endDate)
{
bool resulta = startDate < endDate; // break here
bool resultb = endDate > startDate; // break here
return startDate < endDate && endDate > startDate;
}
// おっと、すでに回答されていることに気づきませんでした