0
public FeeDetails GetFeeDetails(string admissionno)
{
var feedetails = from f in db.FeeDetails select f;
FeeDetails feedetail = feedetails.Where(f => f.AdmissionNo == admissionno).FirstOrDefault();
FeeDetails feedetailfinal = new FeeDetails();
feedetailfinal.Fee1 = feedetail.Fee1.ToString() != null ? Convert.ToInt32(feedetail.Fee1.ToString()) : 0;
feedetailfinal.Fee2 = feedetail.Fee2.ToString() != null ? Convert.ToInt32(feedetail.Fee2.ToString()) : 0;
feedetailfinal.Fee3 = feedetail.Fee3.ToString() != null ? Convert.ToInt32(feedetail.Fee3.ToString()) : 0;
feedetailfinal.Fee4 = feedetail.Fee4.ToString() != null ? Convert.ToInt32(feedetail.Fee4.ToString()) : 0;
feedetailfinal.Fee5 = feedetail.Fee5.ToString() != null ? Convert.ToInt32(feedetail.Fee5.ToString()) : 0;
return feedetailfinal;
}
確定'feedetail'沒有'null'? – Mairaj
把一個檢查'if(feedetail!= null)'然後訪問它的值。 – Mairaj
哪一行你得到這個錯誤? – A3006