小编use*_*055的帖子

Nullable DateTime中的年份

如何计算nullable日期中的年份?

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--;
    }
}
Run Code Online (Sandbox Code Playgroud)

错误是:

'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?)   
Run Code Online (Sandbox Code Playgroud)

.net c#

14
推荐指数
2
解决办法
1万
查看次数

标签 统计

.net ×1

c# ×1