Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nullable TimeSpan? to TimeSpan [closed]

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
like image 775
Newbie2DotNet Avatar asked Mar 19 '15 15:03

Newbie2DotNet


1 Answers

TimeSpan? timestamp = DateTime.Now - modelXyz.DateStamp;
if(timestamp.HasValue)
{
    TimeSpan nonNullableTS = timestamp.Value;
}
like image 185
granadaCoder Avatar answered Sep 27 '22 17:09

granadaCoder