I have 2 Nullable Datetime field's in a method. How to select minimum of 2.
I tried below:
static void GetMinimunDate(DateTime? startDate,DateTime? copDateTime)
{
DateTime? retDate = DateTime.MinValue;
if (startDate == null && copDateTime == null)
{
}
else if(startDate.HasValue && copDateTime.HasValue)
{
retDate = startDate < copDateTime ? startDate : copDateTime;
}
else if (startDate == null)
{
retDate = copDateTime;
}
else
{
retDate = startDate;
}
}