Как я могу рассчитать год на nullable
?Год в Nullable DateTime
partial void AgeAtDiagnosis_Compute(ref int result)
{
// Set result to the desired field value
result = DateofDiagnosis.Year - DateofBirth.Year;
if (DateofBirth > DateofDiagnosis.AddYears(-result))
{
result--;
}
}
Ошибка:
'System.Nullable<System.DateTime>' does not contain a definition for 'Year' and no
extension method 'Year' accepting a first argument of
type 'System.Nullable<System.DateTime>' could be found (are you missing a using
directive or an assembly reference?)
ли работа с реальным DateTime? Если вы не можете использовать ненулевое значение. Похоже, если это нулевой расчет года, в любом случае не нужен? – TGH
Вам необходимо найти google https://www.google.co.in/search?q=nullable+datetime+in+c%23 – Prakash