c# calculate difference between two dates in days

C#
(EndDate - StartDate).TotalDays //double
(EndDate.Date - StartDate.Date).Days //int
Source

Also in C#: