¿Cómo puedo calcular el año en una fecha de nullable
?Año en Nullable FechaTiempo
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--;
}
}
El error es:
'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?)
¿funciona con DateTime real? Si es así, no puedes usar el valor no nulo. Parece que si es nulo, ¿no es necesario el cálculo del año? – TGH
Debes haber buscado google https://www.google.co.in/search?q=nullable+datetime+in+c%23 – Prakash