如何将此C#代码行从Nullable TimeSpan转换为TimeSpan 由于DateStamp是Nullable DateTime
TimeSpan? timestamp = DateTime.Now - modelXyz.DateStamp
答案 0 :(得分:5)
TimeSpan? timestamp = DateTime.Now - modelXyz.DateStamp
if(timestamp.HasValue)
{
TimeSpan nonNullableTS = timestamp.Value;
}