0

私は自分のクラスでこれを定義します

 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: より良い解決策はありますか?

4

1 に答える 1