If I have a method:
protected int CalculateActualDuration(DateTime? startDate, DateTime? endDate) {
if (startDate.HasValue && endDate.HasValue) {
return Math.Abs((int)(endDate.Value.Subtract(startDate.Value).TotalMinutes));
}
else {
return 0;
}
}
I am able to call the method by passing in both a DateTime? and a DateTime. So how does the compiler understand the difference?
Does that mean if I pass in a DateTime Value, the if statement will essentially be soemthing like
if (true && true)
and all the *.value has been changed to the proper objects? So all endDate.Value are all now EndDates?
Does the compiler cast all parameters that are not Nullables into Nullables during runtime?