I've a GCalendar
class that interact with Google Calendar API
:
public class GEvent
{
public DateTime StartDate { get; set; }
public TimeSpan StartTime { get; set; }
public DateTime EndDate { get; set; }
public TimeSpan EndTime { get; set; }
}
how you can see there are two properties StartTime
and EndTime
that is both TimeSpan
.
Now I've created an object that instantiates this class, like so:
Calendar.GEvent eventD = new Calendar.GEvent();
I take the value of the StartTime
and EndTime
from a custom control. This control however return a DateTime
instead of a TimeSpan
, so I need to convert the DateTime
into TimeSpan
. This is what I did:
eventD.StartTime = new TimeSpan((long)EventTimeStart.SelectedTime.Value);
where EventTimeStart
is the custom control. Now there is a problem the new TimeSpan
waiting for a long, so I tried to implicit cast the control value into (long)
but I get:
Cannot convert the type
System.DateTime
into 'Long'
I also tried with:
long startTime = EventTimeStart.SelectedTime.Value;
but is the same thing. How can I do for fix this?