How do I convert this C# line of code to a TimeSpan from Nullable TimeSpan as DateStamp is Nullable DateTime
TimeSpan? timestamp = DateTime.Now - modelXyz.DateStamp
How do I convert this C# line of code to a TimeSpan from Nullable TimeSpan as DateStamp is Nullable DateTime
TimeSpan? timestamp = DateTime.Now - modelXyz.DateStamp
TimeSpan? timestamp = DateTime.Now - modelXyz.DateStamp;
if(timestamp.HasValue)
{
TimeSpan nonNullableTS = timestamp.Value;
}
if (modelXyz.DateStamp.HasValue) { TimeSpan nonNullableTS = DateTime.Now - modelXyz.DateStamp.Value; /* use the time span here */ }
–
Acromegaly © 2022 - 2024 — McMap. All rights reserved.
DateStamp
is actually null? Can we assume that will not happen? – Acromegaly