に私は休暇日時ピッカーに戻り、1/1/0001午前12:00:00 C#の
私のクラスでこれを定めるpublic DateTime? LineCheckSubmitDateTime { set; get; }
私は私のgridview
しかし、時にはので、ここで私はnullで、この値を残しておく必要がありますが、私はそれを残すとき、それは1/1/0001 12:00:00 AM
を返すには、私のコードです:
newObj.LineCheckSubmitDateTime = (Convert.ToDateTime(gridViewDetails.GetRowCellValue(rowHandle, "LineCheckSubmitDateTime"))==DateTime.Parse("1/1/0001 12:00:00 AM")) ? Convert.ToDateTime(gridViewDetails.GetRowCellValue(rowHandle, "LineCheckSubmitDateTime")):null;
ので、2つの質問:
1:このコードは、このエラーを返します:
Severity Code Description Project File Line
Error CS0173 Type of conditional expression cannot be determined because there is no implicit conversion between 'DateTime' and '<null>'
2:あなたは、より良い解決策を持っているのですか?
同じエラーが返される –
@EhsanAkbarは、「DateTime?」の代わりに「DateTime」というコードで間違いを犯しました。コードが変更されました。それはうまくいくはずです。 – Habib
残念ながら、私は同じエラーがありますか?コードを変更しますか? –